public
Created

  • Download Gist
gistfile1.diff
Diff
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 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
From f750e1fdbd0cf0ec0e791709fd204aaeb7781bb1 Mon Sep 17 00:00:00 2001
From: Johannes Pfau <johannespfau@gmail.com>
Date: Sat, 2 Feb 2013 22:53:21 +0100
Subject: [PATCH] Implement D predefined OS versions
 
This implements the following official versions:
* Windows
** Win32
** Win64
** Cygwin
** MinGW
* linux
* OSX
* FreeBSD
* OpenBSD
* NetBSD
* Solaris
* Posix
* AIX
* SysV4
* Hurd
* Android
 
These gdc specific versions are also implemented:
* GDC_MinGW64 (for mingw-w64)
* GDC_OpenSolaris (for opensolaris)
* GDC_GLibc (implemented for linux & bsd & opensolaris)
* GDC_UCLibc (implemented for linux)
* GDC_Bionic (implemented for linux)
 
These official OS versions are not implemented:
* DragonFlyBSD
* BSD (other BSDs)
* Haiku
* SkyOS
* SysV3
---
arm/linux-eabi.h | 9 +++++++++
darwin.h | 6 ++++++
freebsd.h | 7 +++++++
gnu.h | 8 ++++++++
i386/cygwin.h | 7 +++++++
i386/linux-common.h | 9 +++++++++
i386/mingw-w64.h | 7 +++++++
i386/mingw32.h | 12 ++++++++++++
i386/sysv4.h | 7 +++++++
ia64/sysv4.h | 7 +++++++
kfreebsd-gnu.h | 8 ++++++++
knetbsd-gnu.h | 10 ++++++++++
kopensolaris-gnu.h | 10 ++++++++++
linux-android.h | 6 ++++++
linux.h | 14 ++++++++++++++
mips/linux-common.h | 9 +++++++++
netbsd.h | 8 ++++++++
openbsd.h | 8 ++++++++
rs6000/aix.h | 7 +++++++
rs6000/sysv4.h | 7 +++++++
sparc/sysv4.h | 7 +++++++
21 files changed, 173 insertions(+)
 
diff --git a/config/arm/linux-eabi.h b/config/arm/linux-eabi.h
index 4a425c8..968930d 100644
--- a/config/arm/linux-eabi.h
+++ b/config/arm/linux-eabi.h
@@ -30,6 +30,15 @@
} \
while (false)
+#undef TARGET_OS_D_BUILTINS
+#define TARGET_OS_D_BUILTINS() \
+ do \
+ { \
+ TARGET_GENERIC_LINUX_OS_D_BUILTINS(); \
+ ANDROID_TARGET_OS_D_BUILTINS(); \
+ } \
+ while (false)
+
/* We default to a soft-float ABI so that binaries can run on all
target hardware. If you override this to use the hard-float ABI then
change the setting of GLIBC_DYNAMIC_LINKER_DEFAULT as well. */
diff --git a/config/darwin.h b/config/darwin.h
index 1e7b9c7..300fd07 100644
--- a/config/darwin.h
+++ b/config/darwin.h
@@ -920,4 +920,10 @@ extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **);
providing an osx-version-min of this unless overridden by the User. */
#define DEF_MIN_OSX_VERSION "10.4"
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ builtin_define ("OSX"); \
+ builtin_define ("Posix"); \
+ } while (0)
+
#endif /* CONFIG_DARWIN_H */
diff --git a/config/freebsd.h b/config/freebsd.h
index 87c0acf..c1e5248 100644
--- a/config/freebsd.h
+++ b/config/freebsd.h
@@ -32,6 +32,13 @@ along with GCC; see the file COPYING3. If not see
#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() FBSD_TARGET_OS_CPP_BUILTINS()
+#undef TARGET_OS_D_BUILTINS
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ builtin_define ("FreeBSD"); \
+ builtin_define ("Posix"); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC FBSD_CPP_SPEC
diff --git a/config/gnu.h b/config/gnu.h
index 604ba8d..224ce8e 100644
--- a/config/gnu.h
+++ b/config/gnu.h
@@ -39,3 +39,11 @@ along with GCC. If not, see <http://www.gnu.org/licenses/>.
builtin_assert ("system=unix"); \
builtin_assert ("system=posix"); \
} while (0)
+
+#undef TARGET_OS_D_BUILTINS
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ \
+ builtin_define ("Hurd"); \
+ builtin_define ("Posix"); \
+ } while (0)
diff --git a/config/i386/cygwin.h b/config/i386/cygwin.h
index de0a3fd..90d255a 100644
--- a/config/i386/cygwin.h
+++ b/config/i386/cygwin.h
@@ -20,6 +20,13 @@ along with GCC; see the file COPYING3. If not see
#define EXTRA_OS_CPP_BUILTINS() /* Nothing. */
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ builtin_define ("Windows"); \
+ builtin_define ("Cygwin"); \
+ builtin_define ("Posix"); \
+ } while (0)
+
#undef CPP_SPEC
#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix \
diff --git a/config/i386/linux-common.h b/config/i386/linux-common.h
index 1e8bf6b..cbad04e 100644
--- a/config/i386/linux-common.h
+++ b/config/i386/linux-common.h
@@ -27,6 +27,15 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#undef TARGET_OS_D_BUILTINS
+#define TARGET_OS_D_BUILTINS() \
+ do \
+ { \
+ TARGET_GENERIC_LINUX_OS_D_BUILTINS(); \
+ ANDROID_TARGET_OS_D_BUILTINS(); \
+ } \
+ while (0)
+
#undef CC1_SPEC
#define CC1_SPEC \
LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
diff --git a/config/i386/mingw-w64.h b/config/i386/mingw-w64.h
index 633009b..914e2b9 100644
--- a/config/i386/mingw-w64.h
+++ b/config/i386/mingw-w64.h
@@ -84,3 +84,10 @@ along with GCC; see the file COPYING3. If not see
%{static:-Bstatic} %{!static:-Bdynamic} \
%{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \
%(shared_libgcc_undefs)"
+
+#undef TARGET_OS_D_BUILTINS
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ TARGET_GENERIC_MINGW_OS_D_BUILTINS(); \
+ builtin_define ("GDC_MinGW64"); \
+ } while (0)
diff --git a/config/i386/mingw32.h b/config/i386/mingw32.h
index 1ac5544..f693210 100644
--- a/config/i386/mingw32.h
+++ b/config/i386/mingw32.h
@@ -53,6 +53,18 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_OS_D_BUILTINS() TARGET_GENERIC_MINGW_OS_D_BUILTINS()
+#define TARGET_GENERIC_MINGW_OS_D_BUILTINS() \
+ do { \
+ builtin_define ("Windows"); \
+ builtin_define ("MinGW"); \
+ \
+ if (TARGET_64BIT && ix86_abi == MS_ABI) \
+ builtin_define ("Win64"); \
+ else if (!TARGET_64BIT) \
+ builtin_define_std ("Win32"); \
+ } while (0)
+
#ifndef TARGET_USE_PTHREAD_BY_DEFAULT
#define SPEC_PTHREAD1 "pthread"
#define SPEC_PTHREAD2 "!no-pthread"
diff --git a/config/i386/sysv4.h b/config/i386/sysv4.h
index ff24575..0b90d39 100644
--- a/config/i386/sysv4.h
+++ b/config/i386/sysv4.h
@@ -70,3 +70,10 @@ along with GCC; see the file COPYING3. If not see
"|%0,_GLOBAL_OFFSET_TABLE_+(.-.LPR%=)}" \
: "=d"(BASE))
#endif
+
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ \
+ builtin_define ("SysV4"); \
+ builtin_define ("Posix"); \
+ } while (0)
diff --git a/config/ia64/sysv4.h b/config/ia64/sysv4.h
index e55551d..6230022 100644
--- a/config/ia64/sysv4.h
+++ b/config/ia64/sysv4.h
@@ -142,3 +142,10 @@ do { \
#define SDATA_SECTION_ASM_OP "\t.sdata"
#define SBSS_SECTION_ASM_OP "\t.sbss"
+
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ \
+ builtin_define ("SysV4"); \
+ builtin_define ("Posix"); \
+ } while (0)
diff --git a/config/kfreebsd-gnu.h b/config/kfreebsd-gnu.h
index 4f07a24..0dc98a2 100644
--- a/config/kfreebsd-gnu.h
+++ b/config/kfreebsd-gnu.h
@@ -29,6 +29,14 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#undef TARGET_OS_D_BUILTINS
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ builtin_define ("FreeBSD"); \
+ builtin_define ("Posix"); \
+ builtin_define ("GDC_GLibc"); \
+ } while (0)
+
#define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
#define GNU_USER_DYNAMIC_LINKER32 GLIBC_DYNAMIC_LINKER32
#define GNU_USER_DYNAMIC_LINKER64 GLIBC_DYNAMIC_LINKER64
diff --git a/config/knetbsd-gnu.h b/config/knetbsd-gnu.h
index 75d9e11..bf2ba1d 100644
--- a/config/knetbsd-gnu.h
+++ b/config/knetbsd-gnu.h
@@ -30,6 +30,16 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#undef TARGET_OS_D_BUILTINS
+#define TARGET_OS_D_BUILTINS() \
+ do \
+ { \
+ builtin_define ("NetBSD"); \
+ builtin_define ("Posix"); \
+ builtin_define ("GDC_GLibc"); \
+ } \
+ while (0)
+
#undef GNU_USER_DYNAMIC_LINKER
#define GNU_USER_DYNAMIC_LINKER "/lib/ld.so.1"
diff --git a/config/kopensolaris-gnu.h b/config/kopensolaris-gnu.h
index 1d800bb..2d98dae 100644
--- a/config/kopensolaris-gnu.h
+++ b/config/kopensolaris-gnu.h
@@ -30,5 +30,15 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_OS_D_BUILTINS() \
+ do \
+ { \
+ builtin_define ("Solaris"); \
+ builtin_define ("Posix"); \
+ builtin_define ("GDC_OpenSolaris"); \
+ builtin_define ("GDC_GLibc"); \
+ } \
+ while (0)
+
#undef GNU_USER_DYNAMIC_LINKER
#define GNU_USER_DYNAMIC_LINKER "/lib/ld.so.1"
diff --git a/config/linux-android.h b/config/linux-android.h
index 2c87c84..73eea55 100644
--- a/config/linux-android.h
+++ b/config/linux-android.h
@@ -25,6 +25,12 @@
builtin_define ("__ANDROID__"); \
} while (0)
+#define ANDROID_TARGET_OS_D_BUILTINS() \
+ do { \
+ if (TARGET_ANDROID) \
+ builtin_define ("Android"); \
+ } while (0)
+
#if ANDROID_DEFAULT
# define NOANDROID "mno-android"
#else
diff --git a/config/linux.h b/config/linux.h
index 2be1079..af9a9a6 100644
--- a/config/linux.h
+++ b/config/linux.h
@@ -49,6 +49,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
builtin_assert ("system=posix"); \
} while (0)
+#define TARGET_OS_D_BUILTINS() TARGET_GENERIC_LINUX_OS_D_BUILTINS()
+#define TARGET_GENERIC_LINUX_OS_D_BUILTINS() \
+ do { \
+ if (OPTION_GLIBC) \
+ builtin_define ("GDC_GLibc"); \
+ else if (OPTION_UCLIBC) \
+ builtin_define ("GDC_UCLibc"); \
+ else if (OPTION_BIONIC) \
+ builtin_define ("GDC_Bionic"); \
+ \
+ builtin_define ("linux"); \
+ builtin_define ("Posix"); \
+ } while (0)
+
/* Determine which dynamic linker to use depending on whether GLIBC or
uClibc or Bionic is the default C library and whether
-muclibc or -mglibc or -mbionic has been passed to change the default. */
diff --git a/config/mips/linux-common.h b/config/mips/linux-common.h
index ca4ea07..d6a9931 100644
--- a/config/mips/linux-common.h
+++ b/config/mips/linux-common.h
@@ -27,6 +27,15 @@ along with GCC; see the file COPYING3. If not see
ANDROID_TARGET_OS_CPP_BUILTINS(); \
} while (0)
+#undef TARGET_OS_D_BUILTINS
+#define TARGET_OS_D_BUILTINS() \
+ do \
+ { \
+ TARGET_GENERIC_LINUX_OS_D_BUILTINS(); \
+ ANDROID_TARGET_OS_D_BUILTINS(); \
+ } \
+ while (0)
+
#undef LINK_SPEC
#define LINK_SPEC \
LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
diff --git a/config/netbsd.h b/config/netbsd.h
index 71c9183..e564007 100644
--- a/config/netbsd.h
+++ b/config/netbsd.h
@@ -29,6 +29,14 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_OS_D_BUILTINS() \
+ do \
+ { \
+ builtin_define ("NetBSD"); \
+ builtin_define ("Posix"); \
+ } \
+ while (0)
+
/* CPP_SPEC parts common to all NetBSD targets. */
#define NETBSD_CPP_SPEC \
"%{posix:-D_POSIX_SOURCE} \
diff --git a/config/openbsd.h b/config/openbsd.h
index 6537451..d8fbb6b 100644
--- a/config/openbsd.h
+++ b/config/openbsd.h
@@ -84,6 +84,14 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define TARGET_OS_D_BUILTINS() \
+ do \
+ { \
+ builtin_define ("OpenBSD"); \
+ builtin_define ("Posix"); \
+ } \
+ while (0)
+
/* TARGET_OS_CPP_BUILTINS() common to all OpenBSD ELF targets. */
#define OPENBSD_OS_CPP_BUILTINS_ELF() \
do \
diff --git a/config/rs6000/aix.h b/config/rs6000/aix.h
index f81666a..5352f23 100644
--- a/config/rs6000/aix.h
+++ b/config/rs6000/aix.h
@@ -110,6 +110,13 @@
} \
while (0)
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ \
+ builtin_define ("AIX"); \
+ builtin_define ("Posix"); \
+ } while (0)
+
/* Define appropriate architecture macros for preprocessor depending on
target switches. */
diff --git a/config/rs6000/sysv4.h b/config/rs6000/sysv4.h
index 54bdb21..c55470e 100644
--- a/config/rs6000/sysv4.h
+++ b/config/rs6000/sysv4.h
@@ -523,6 +523,13 @@ extern int fixuplabelno;
while (0)
#endif
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ \
+ builtin_define ("SysV4"); \
+ builtin_define ("Posix"); \
+ } while (0)
+
#undef ASM_SPEC
#define ASM_SPEC "%(asm_cpu) \
%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \
diff --git a/config/sparc/sysv4.h b/config/sparc/sysv4.h
index 1849414..4be48f0 100644
--- a/config/sparc/sysv4.h
+++ b/config/sparc/sysv4.h
@@ -117,3 +117,10 @@ do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \
#undef MCOUNT_FUNCTION
#define MCOUNT_FUNCTION "*_mcount"
+
+#define TARGET_OS_D_BUILTINS() \
+ do { \
+ \
+ builtin_define ("SysV4"); \
+ builtin_define ("Posix"); \
+ } while (0)
--
1.7.11.7

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.