1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
/***
* D compatible types that correspond to various basic types in associated
* C and C++ compilers.
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Sean Kelly
* Source: $(DRUNTIMESRC core/stdc/_config.d)
* Standards: ISO/IEC 9899:1999 (E)
*/
/* NOTE: This file has been patched from the original DMD distribution to
* work with the GDC compiler.
*/
module core.stdc.config;
version (StdDdoc)
{
private
{
version (Posix)
enum isPosix = true;
else
enum isPosix = false;
static if (isPosix && (void*).sizeof > int.sizeof)
{
alias ddoc_long = long;
alias ddoc_ulong = ulong;
}
else
{
alias ddoc_long = int;
alias ddoc_ulong = uint;
}
struct ddoc_complex(T) { T re; T im; }
}
/***
* Used for a signed integer type that corresponds in size to the associated
* C compiler's `long` type.
*/
alias c_long = ddoc_long;
/***
* Used for an unsigned integer type that corresponds in size to the associated
* C compiler's `unsigned long` type.
*/
alias c_ulong = ddoc_ulong;
/***
* Used for a signed integer type that corresponds in size and mangling to the associated
* C++ compiler's `long` type.
*/
alias cpp_long = c_long;
/***
* Used for an unsigned integer type that corresponds in size and mangling to the associated
* C++ compiler's `unsigned long` type.
*/
alias cpp_ulong = c_ulong;
/***
* Used for a signed integer type that corresponds in size and mangling to the associated
* C++ compiler's `long long` type.
*/
alias cpp_longlong = long;
/***
* Used for an unsigned integer type that corresponds in size and mangling to the associated
* C++ compiler's `unsigned long long` type.
*/
alias cpp_ulonglong = ulong;
/***
* Used for a floating point type that corresponds in size and mangling to the associated
* C++ compiler's `long double` type.
*/
alias c_long_double = real;
/***
* Used for an unsigned integer type that corresponds in size and mangling to the associated
* C++ compiler's `size_t` type.
*/
alias cpp_size_t = size_t;
/***
* Used for a signed integer type that corresponds in size and mangling to the associated
* C++ compiler's `ptrdiff_t` type.
*/
alias cpp_ptrdiff_t = ptrdiff_t;
/***
* Used for a complex floating point type that corresponds in size and ABI to the associated
* C compiler's `_Complex float` type.
*/
alias c_complex_float = ddoc_complex!float;
/***
* Used for a complex floating point type that corresponds in size and ABI to the associated
* C compiler's `_Complex double` type.
*/
alias c_complex_double = ddoc_complex!double;
/***
* Used for a complex floating point type that corresponds in size and ABI to the associated
* C compiler's `_Complex long double` type.
*/
alias c_complex_real = ddoc_complex!real;
}
else
{
version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;
version (GNU)
{
import gcc.builtins;
alias __builtin_clong c_long;
alias __builtin_culong c_ulong;
enum __c_long : __builtin_clong;
enum __c_ulong : __builtin_culong;
alias __c_long cpp_long;
alias __c_ulong cpp_ulong;
enum __c_longlong : __builtin_clonglong;
enum __c_ulonglong : __builtin_culonglong;
alias __c_longlong cpp_longlong;
alias __c_ulonglong cpp_ulonglong;
}
else version (Windows)
{
enum __c_long : int;
enum __c_ulong : uint;
alias int c_long;
alias uint c_ulong;
alias __c_long cpp_long;
alias __c_ulong cpp_ulong;
alias long cpp_longlong;
alias ulong cpp_ulonglong;
}
else version (Posix)
{
static if ( (void*).sizeof > int.sizeof )
{
enum __c_longlong : long;
enum __c_ulonglong : ulong;
alias long c_long;
alias ulong c_ulong;
alias long cpp_long;
alias ulong cpp_ulong;
alias __c_longlong cpp_longlong;
alias __c_ulonglong cpp_ulonglong;
}
else
{
enum __c_long : int;
enum __c_ulong : uint;
alias int c_long;
alias uint c_ulong;
alias __c_long cpp_long;
alias __c_ulong cpp_ulong;
alias long cpp_longlong;
alias ulong cpp_ulonglong;
}
}
version (GNU)
alias c_long_double = real;
else version (LDC)
alias c_long_double = real; // 64-bit real for MSVC targets
else version (SDC)
{
version (X86)
alias c_long_double = real;
else version (X86_64)
alias c_long_double = real;
}
else version (CRuntime_Microsoft)
{
/* long double is 64 bits, not 80 bits, but is mangled differently
* than double. To distinguish double from long double, create a wrapper to represent
* long double, then recognize that wrapper specially in the compiler
* to generate the correct name mangling and correct function call/return
* ABI conformance.
*/
enum __c_long_double : double;
alias __c_long_double c_long_double;
}
else version (DigitalMars)
{
version (X86)
{
alias real c_long_double;
}
else version (X86_64)
{
version (linux)
alias real c_long_double;
else version (FreeBSD)
alias real c_long_double;
else version (OpenBSD)
alias real c_long_double;
else version (NetBSD)
alias real c_long_double;
else version (DragonFlyBSD)
alias real c_long_double;
else version (Solaris)
alias real c_long_double;
else version (Darwin)
alias real c_long_double;
}
}
static assert(is(c_long_double), "c_long_double needs to be declared for this platform/architecture.");
version (Darwin)
{
alias cpp_size_t = cpp_ulong;
version (D_LP64)
alias cpp_ptrdiff_t = cpp_long;
else
alias cpp_ptrdiff_t = ptrdiff_t;
}
else
{
alias cpp_size_t = size_t;
alias cpp_ptrdiff_t = ptrdiff_t;
}
// ABI layout of native complex types.
private struct _Complex(T)
{
T re;
T im;
}
enum __c_complex_float : _Complex!float;
enum __c_complex_double : _Complex!double;
enum __c_complex_real : _Complex!c_long_double;
alias c_complex_float = __c_complex_float;
alias c_complex_double = __c_complex_double;
alias c_complex_real = __c_complex_real;
}
|