aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/dmd/root
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2018-11-04 23:34:44 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2018-11-04 23:34:44 +0000
commitf9ab59ffe7f22c533df54f28cd7e71affbce854b (patch)
tree450d012939fe9a9d4435c2cf7002a626c0431429 /gcc/d/dmd/root
parente8bf3d5ed983791a658b86f4eae338e13b6fdc3f (diff)
downloadgcc-f9ab59ffe7f22c533df54f28cd7e71affbce854b.zip
gcc-f9ab59ffe7f22c533df54f28cd7e71affbce854b.tar.gz
gcc-f9ab59ffe7f22c533df54f28cd7e71affbce854b.tar.bz2
Merge dmd upstream 6243fa6d2
This introduces a new header that pulls in system includes for use only in the DMD front-end part of the compiler, fixing up uses of problematic functions that are prevalent throughout the code. Commits merged from dmd. Fix build of the D frontend on the Hurd and KFreeBSD. Initial patch from Matthias Klose. https://github.com/dlang/dmd/pull/8893 Don't care about D/C++ compatibility in C++ port. Fixes build error in https://gcc.gnu.org/PR87788 https://github.com/dlang/dmd/pull/8895 Allow compiling front-end headers with strict warnings. https://github.com/dlang/dmd/pull/8909 Add root/system.h header for wrapping system includes. Fixes https://gcc.gnu.org/PR87865 https://github.com/dlang/dmd/pull/8910 Move checkedint to dmd/root. https://github.com/dlang/dmd/pull/8912 Use rmem instead of libc for malloc() and strdup(). https://github.com/dlang/dmd/pull/8913 Use align(8) for alignment of UnionExp, fixing several BUS errors due to alignment issues on SPARC. https://github.com/dlang/dmd/pull/8914 Don't pass NULL pointer as format parameter to errorSupplemental. https://github.com/dlang/dmd/pull/8916 gcc/d/ChangeLog: 2018-11-05 Iain Buclaw <ibuclaw@gdcproject.org> PR d/87865 * d-system.h: New file. From-SVN: r265780
Diffstat (limited to 'gcc/d/dmd/root')
-rw-r--r--gcc/d/dmd/root/aav.c6
-rw-r--r--gcc/d/dmd/root/aav.h2
-rw-r--r--gcc/d/dmd/root/array.h6
-rw-r--r--gcc/d/dmd/root/checkedint.c238
-rw-r--r--gcc/d/dmd/root/checkedint.h30
-rw-r--r--gcc/d/dmd/root/dcompat.h2
-rw-r--r--gcc/d/dmd/root/dsystem.h24
-rw-r--r--gcc/d/dmd/root/file.c25
-rw-r--r--gcc/d/dmd/root/file.h3
-rw-r--r--gcc/d/dmd/root/filename.c20
-rw-r--r--gcc/d/dmd/root/hash.h3
-rw-r--r--gcc/d/dmd/root/object.h6
-rw-r--r--gcc/d/dmd/root/outbuffer.c11
-rw-r--r--gcc/d/dmd/root/outbuffer.h5
-rw-r--r--gcc/d/dmd/root/port.h4
-rw-r--r--gcc/d/dmd/root/rmem.c37
-rw-r--r--gcc/d/dmd/root/rmem.h2
-rw-r--r--gcc/d/dmd/root/rootobject.c3
-rw-r--r--gcc/d/dmd/root/speller.c11
-rw-r--r--gcc/d/dmd/root/stringtable.c6
20 files changed, 352 insertions, 92 deletions
diff --git a/gcc/d/dmd/root/aav.c b/gcc/d/dmd/root/aav.c
index 4c015bf..931a395 100644
--- a/gcc/d/dmd/root/aav.c
+++ b/gcc/d/dmd/root/aav.c
@@ -11,11 +11,7 @@
*
*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
+#include "dsystem.h"
#include "aav.h"
#include "rmem.h"
diff --git a/gcc/d/dmd/root/aav.h b/gcc/d/dmd/root/aav.h
index 24c281a..ad57cb4 100644
--- a/gcc/d/dmd/root/aav.h
+++ b/gcc/d/dmd/root/aav.h
@@ -8,6 +8,8 @@
#pragma once
+#include "dsystem.h"
+
typedef void* Value;
typedef void* Key;
diff --git a/gcc/d/dmd/root/array.h b/gcc/d/dmd/root/array.h
index ed128b9..dd28998 100644
--- a/gcc/d/dmd/root/array.h
+++ b/gcc/d/dmd/root/array.h
@@ -7,11 +7,7 @@
#pragma once
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
+#include "dsystem.h"
#include "object.h"
#include "rmem.h"
diff --git a/gcc/d/dmd/root/checkedint.c b/gcc/d/dmd/root/checkedint.c
new file mode 100644
index 0000000..392904a
--- /dev/null
+++ b/gcc/d/dmd/root/checkedint.c
@@ -0,0 +1,238 @@
+
+/**********************************************
+ * This module implements integral arithmetic primitives that check
+ * for out-of-range results.
+ * This is a translation to C++ of D's core.checkedint
+ *
+ * Integral arithmetic operators operate on fixed width types.
+ * Results that are not representable in those fixed widths are silently
+ * truncated to fit.
+ * This module offers integral arithmetic primitives that produce the
+ * same results, but set an 'overflow' flag when such truncation occurs.
+ * The setting is sticky, meaning that numerous operations can be cascaded
+ * and then the flag need only be checked at the end.
+ * Whether the operation is signed or unsigned is indicated by an 's' or 'u'
+ * suffix, respectively. While this could be achieved without such suffixes by
+ * using overloading on the signedness of the types, the suffix makes it clear
+ * which is happening without needing to examine the types.
+ *
+ * While the generic versions of these functions are computationally expensive
+ * relative to the cost of the operation itself, compiler implementations are free
+ * to recognize them and generate equivalent and faster code.
+ *
+ * References: $(LINK2 http://blog.regehr.org/archives/1139, Fast Integer Overflow Checks)
+ * Copyright: Copyright (C) 2014-2018 by The D Language Foundation, All Rights Reserved
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors: Walter Bright
+ * Source: https://github.com/D-Programming-Language/dmd/blob/master/src/root/checkedint.c
+ */
+
+#include "dsystem.h"
+#include "checkedint.h"
+
+
+/*******************************
+ * Add two signed integers, checking for overflow.
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ * x = left operand
+ * y = right operand
+ * overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ * the sum
+ */
+
+int adds(int x, int y, bool& overflow)
+{
+ int64_t r = (int64_t)x + (int64_t)y;
+ if (r < INT32_MIN || r > INT32_MAX)
+ overflow = true;
+ return (int)r;
+}
+
+/// ditto
+int64_t adds(int64_t x, int64_t y, bool& overflow)
+{
+ int64_t r = (uint64_t)x + (uint64_t)y;
+ if ((x < 0 && y < 0 && r >= 0) ||
+ (x >= 0 && y >= 0 && r < 0))
+ overflow = true;
+ return r;
+}
+
+/*******************************
+ * Add two unsigned integers, checking for overflow (aka carry).
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ * x = left operand
+ * y = right operand
+ * overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ * the sum
+ */
+
+unsigned addu(unsigned x, unsigned y, bool& overflow)
+{
+ unsigned r = x + y;
+ if (r < x || r < y)
+ overflow = true;
+ return r;
+}
+
+/// ditto
+uint64_t addu(uint64_t x, uint64_t y, bool& overflow)
+{
+ uint64_t r = x + y;
+ if (r < x || r < y)
+ overflow = true;
+ return r;
+}
+
+/*******************************
+ * Subtract two signed integers, checking for overflow.
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ * x = left operand
+ * y = right operand
+ * overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ * the sum
+ */
+
+int subs(int x, int y, bool& overflow)
+{
+ int64_t r = (int64_t)x - (int64_t)y;
+ if (r < INT32_MIN || r > INT32_MAX)
+ overflow = true;
+ return (int)r;
+}
+
+/// ditto
+int64_t subs(int64_t x, int64_t y, bool& overflow)
+{
+ int64_t r = (uint64_t)x - (uint64_t)y;
+ if ((x < 0 && y >= 0 && r >= 0) ||
+ (x >= 0 && y < 0 && (r < 0 || y == INT64_MIN)))
+ overflow = true;
+ return r;
+}
+
+/*******************************
+ * Subtract two unsigned integers, checking for overflow (aka borrow).
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ * x = left operand
+ * y = right operand
+ * overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ * the sum
+ */
+
+unsigned subu(unsigned x, unsigned y, bool& overflow)
+{
+ if (x < y)
+ overflow = true;
+ return x - y;
+}
+
+/// ditto
+uint64_t subu(uint64_t x, uint64_t y, bool& overflow)
+{
+ if (x < y)
+ overflow = true;
+ return x - y;
+}
+
+/***********************************************
+ * Negate an integer.
+ *
+ * Params:
+ * x = operand
+ * overflow = set if x cannot be negated, is not affected otherwise
+ * Returns:
+ * the negation of x
+ */
+
+int negs(int x, bool& overflow)
+{
+ if (x == (int)INT32_MIN)
+ overflow = true;
+ return -x;
+}
+
+/// ditto
+int64_t negs(int64_t x, bool& overflow)
+{
+ if (x == INT64_MIN)
+ overflow = true;
+ return -x;
+}
+
+/*******************************
+ * Multiply two signed integers, checking for overflow.
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ * x = left operand
+ * y = right operand
+ * overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ * the sum
+ */
+
+int muls(int x, int y, bool& overflow)
+{
+ int64_t r = (int64_t)x * (int64_t)y;
+ if (r < INT32_MIN || r > INT32_MAX)
+ overflow = true;
+ return (int)r;
+}
+
+/// ditto
+int64_t muls(int64_t x, int64_t y, bool& overflow)
+{
+ int64_t r = (uint64_t)x * (uint64_t)y;
+ int64_t not0or1 = ~(int64_t)1;
+ if ((x & not0or1) && ((r == y) ? r : (r / x) != y))
+ overflow = true;
+ return r;
+}
+
+/*******************************
+ * Multiply two unsigned integers, checking for overflow (aka carry).
+ *
+ * The overflow is sticky, meaning a sequence of operations can
+ * be done and overflow need only be checked at the end.
+ * Params:
+ * x = left operand
+ * y = right operand
+ * overflow = set if an overflow occurs, is not affected otherwise
+ * Returns:
+ * the sum
+ */
+
+unsigned mulu(unsigned x, unsigned y, bool& overflow)
+{
+ uint64_t r = (uint64_t)x * (uint64_t)y;
+ if (r > UINT32_MAX)
+ overflow = true;
+ return (unsigned)r;
+}
+
+/// ditto
+uint64_t mulu(uint64_t x, uint64_t y, bool& overflow)
+{
+ uint64_t r = x * y;
+ if (x && (r / x) != y)
+ overflow = true;
+ return r;
+}
diff --git a/gcc/d/dmd/root/checkedint.h b/gcc/d/dmd/root/checkedint.h
new file mode 100644
index 0000000..1362ff5
--- /dev/null
+++ b/gcc/d/dmd/root/checkedint.h
@@ -0,0 +1,30 @@
+
+/* Compiler implementation of the D programming language
+ * Copyright (C) 2003-2018 by The D Language Foundation, All Rights Reserved
+ * written by Walter Bright
+ * http://www.digitalmars.com
+ * Distributed under the Boost Software License, Version 1.0.
+ * http://www.boost.org/LICENSE_1_0.txt
+ * https://github.com/D-Programming-Language/dmd/blob/master/src/root/checkedint.h
+ */
+
+#include "dsystem.h"
+
+
+int adds(int x, int y, bool& overflow);
+int64_t adds(int64_t x, int64_t y, bool& overflow);
+unsigned addu(unsigned x, unsigned y, bool& overflow);
+uint64_t addu(uint64_t x, uint64_t y, bool& overflow);
+
+int subs(int x, int y, bool& overflow);
+int64_t subs(int64_t x, int64_t y, bool& overflow);
+unsigned subu(unsigned x, unsigned y, bool& overflow);
+uint64_t subu(uint64_t x, uint64_t y, bool& overflow);
+
+int negs(int x, bool& overflow);
+int64_t negs(int64_t x, bool& overflow);
+
+int muls(int x, int y, bool& overflow);
+int64_t muls(int64_t x, int64_t y, bool& overflow);
+unsigned mulu(unsigned x, unsigned y, bool& overflow);
+uint64_t mulu(uint64_t x, uint64_t y, bool& overflow);
diff --git a/gcc/d/dmd/root/dcompat.h b/gcc/d/dmd/root/dcompat.h
index 3fc169c..f92f0ab 100644
--- a/gcc/d/dmd/root/dcompat.h
+++ b/gcc/d/dmd/root/dcompat.h
@@ -9,6 +9,8 @@
#pragma once
+#include "dsystem.h"
+
/// Represents a D [ ] array
template<typename T>
struct DArray
diff --git a/gcc/d/dmd/root/dsystem.h b/gcc/d/dmd/root/dsystem.h
new file mode 100644
index 0000000..940ff50
--- /dev/null
+++ b/gcc/d/dmd/root/dsystem.h
@@ -0,0 +1,24 @@
+/* dsystem.h -- Get common system includes from the host.
+ * Copyright (C) 2018 Free Software Foundation, Inc.
+ *
+ * GCC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GCC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GCC; see the file COPYING3. If not see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+/* This header is used in place of dmd upstream so that we can wrap
+ around gcc's system.h. */
+
+#pragma once
+
+#include "d-system.h"
diff --git a/gcc/d/dmd/root/file.c b/gcc/d/dmd/root/file.c
index f4fd51a..454d4cb 100644
--- a/gcc/d/dmd/root/file.c
+++ b/gcc/d/dmd/root/file.c
@@ -6,29 +6,14 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/file.c
*/
+#include "dsystem.h"
#include "file.h"
-#if defined (__sun)
-#include <alloca.h>
-#endif
-
-#if _MSC_VER ||__MINGW32__
-#include <malloc.h>
-#include <string>
-#endif
-
#if _WIN32
#include <windows.h>
-#include <direct.h>
-#include <errno.h>
#endif
#if POSIX
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
#include <utime.h>
#endif
@@ -104,7 +89,11 @@ bool File::read()
goto err2;
}
size = (size_t)buf.st_size;
+#ifdef IN_GCC
+ buffer = (unsigned char *) ::xmalloc(size + 2);
+#else
buffer = (unsigned char *) ::malloc(size + 2);
+#endif
if (!buffer)
{
printf("\tmalloc error, errno = %d\n",errno);
@@ -155,7 +144,11 @@ err1:
ref = 0;
size = GetFileSize(h,NULL);
+#ifdef IN_GCC
+ buffer = (unsigned char *) ::xmalloc(size + 2);
+#else
buffer = (unsigned char *) ::malloc(size + 2);
+#endif
if (!buffer)
goto err2;
diff --git a/gcc/d/dmd/root/file.h b/gcc/d/dmd/root/file.h
index f6953ab..f4d2937 100644
--- a/gcc/d/dmd/root/file.h
+++ b/gcc/d/dmd/root/file.h
@@ -8,8 +8,7 @@
#pragma once
-#include <stddef.h>
-
+#include "dsystem.h"
#include "array.h"
typedef Array<struct File *> Files;
diff --git a/gcc/d/dmd/root/filename.c b/gcc/d/dmd/root/filename.c
index 307e94f..b0bd1a5 100644
--- a/gcc/d/dmd/root/filename.c
+++ b/gcc/d/dmd/root/filename.c
@@ -6,37 +6,19 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/filename.c
*/
+#include "dsystem.h"
#include "filename.h"
-#include <stdint.h>
-#include <ctype.h>
-
#include "outbuffer.h"
#include "array.h"
#include "file.h"
#include "rmem.h"
-#if defined (__sun)
-#include <alloca.h>
-#endif
-
-#if _MSC_VER ||__MINGW32__
-#include <malloc.h>
-#include <string>
-#endif
-
#if _WIN32
#include <windows.h>
-#include <direct.h>
-#include <errno.h>
#endif
#if POSIX
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
#include <utime.h>
#endif
diff --git a/gcc/d/dmd/root/hash.h b/gcc/d/dmd/root/hash.h
index 1b05672..f1bc6cc 100644
--- a/gcc/d/dmd/root/hash.h
+++ b/gcc/d/dmd/root/hash.h
@@ -10,8 +10,7 @@
#pragma once
-#include <stdint.h> // uint{8|16|32}_t
-#include <stdlib.h>
+#include "dsystem.h" // uint{8|16|32}_t
// MurmurHash2 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
diff --git a/gcc/d/dmd/root/object.h b/gcc/d/dmd/root/object.h
index e9d770d..d465e36 100644
--- a/gcc/d/dmd/root/object.h
+++ b/gcc/d/dmd/root/object.h
@@ -6,11 +6,9 @@
* https://github.com/dlang/dmd/blob/master/src/root/object.h
*/
-#define POSIX (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun)
-
#pragma once
-#include <stddef.h>
+#include "dsystem.h"
typedef size_t hash_t;
@@ -25,7 +23,7 @@ enum DYNCAST
DYNCAST_IDENTIFIER,
DYNCAST_TUPLE,
DYNCAST_PARAMETER,
- DYNCAST_STATEMENT,
+ DYNCAST_STATEMENT
};
/*
diff --git a/gcc/d/dmd/root/outbuffer.c b/gcc/d/dmd/root/outbuffer.c
index 7b6782d..4791bb1 100644
--- a/gcc/d/dmd/root/outbuffer.c
+++ b/gcc/d/dmd/root/outbuffer.c
@@ -6,16 +6,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/outbuffer.c
*/
-#include <assert.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if __sun
-#include <alloca.h>
-#endif
-
+#include "dsystem.h"
#include "outbuffer.h"
#include "object.h"
diff --git a/gcc/d/dmd/root/outbuffer.h b/gcc/d/dmd/root/outbuffer.h
index 6d3be10..6e6b35d 100644
--- a/gcc/d/dmd/root/outbuffer.h
+++ b/gcc/d/dmd/root/outbuffer.h
@@ -8,10 +8,7 @@
#pragma once
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <assert.h>
+#include "dsystem.h"
#include "port.h"
#include "rmem.h"
diff --git a/gcc/d/dmd/root/port.h b/gcc/d/dmd/root/port.h
index 3f3c46d..0dbb319 100644
--- a/gcc/d/dmd/root/port.h
+++ b/gcc/d/dmd/root/port.h
@@ -11,11 +11,9 @@
// Portable wrapper around compiler/system specific things.
// The idea is to minimize #ifdef's in the app code.
-#include <stdlib.h> // for alloca
-#include <stdint.h>
+#include "dsystem.h" // for alloca
#if _MSC_VER
-#include <alloca.h>
typedef __int64 longlong;
typedef unsigned __int64 ulonglong;
#else
diff --git a/gcc/d/dmd/root/rmem.c b/gcc/d/dmd/root/rmem.c
index 92e79ca..d24e012 100644
--- a/gcc/d/dmd/root/rmem.c
+++ b/gcc/d/dmd/root/rmem.c
@@ -6,10 +6,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/rmem.c
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
+#include "dsystem.h"
#include "rmem.h"
/* This implementation of the storage allocator uses the standard C allocation package.
@@ -23,7 +20,11 @@ char *Mem::xstrdup(const char *s)
if (s)
{
+#ifdef IN_GCC
+ p = ::xstrdup(s);
+#else
p = strdup(s);
+#endif
if (p)
return p;
error();
@@ -38,7 +39,11 @@ void *Mem::xmalloc(size_t size)
p = NULL;
else
{
+#ifdef IN_GCC
+ p = ::xmalloc(size);
+#else
p = malloc(size);
+#endif
if (!p)
error();
}
@@ -52,7 +57,11 @@ void *Mem::xcalloc(size_t size, size_t n)
p = NULL;
else
{
+#ifdef IN_GCC
+ p = ::xcalloc(size, n);
+#else
p = calloc(size, n);
+#endif
if (!p)
error();
}
@@ -70,14 +79,22 @@ void *Mem::xrealloc(void *p, size_t size)
}
else if (!p)
{
+#ifdef IN_GCC
+ p = ::xmalloc(size);
+#else
p = malloc(size);
+#endif
if (!p)
error();
}
else
{
void *psave = p;
+#ifdef IN_GCC
+ p = ::xrealloc(psave, size);
+#else
p = realloc(psave, size);
+#endif
if (!p)
{ xfree(psave);
error();
@@ -99,7 +116,11 @@ void *Mem::xmallocdup(void *o, size_t size)
p = NULL;
else
{
+#ifdef IN_GCC
+ p = ::xmalloc(size);
+#else
p = malloc(size);
+#endif
if (!p)
error();
else
@@ -143,7 +164,11 @@ extern "C" void *allocmemory(size_t m_size)
if (m_size > CHUNK_SIZE)
{
+#ifdef IN_GCC
+ void *p = xmalloc(m_size);
+#else
void *p = malloc(m_size);
+#endif
if (p)
return p;
printf("Error: out of memory\n");
@@ -152,7 +177,11 @@ extern "C" void *allocmemory(size_t m_size)
}
heapleft = CHUNK_SIZE;
+#ifdef IN_GCC
+ heapp = xmalloc(CHUNK_SIZE);
+#else
heapp = malloc(CHUNK_SIZE);
+#endif
if (!heapp)
{
printf("Error: out of memory\n");
diff --git a/gcc/d/dmd/root/rmem.h b/gcc/d/dmd/root/rmem.h
index 87d465f..0123402 100644
--- a/gcc/d/dmd/root/rmem.h
+++ b/gcc/d/dmd/root/rmem.h
@@ -8,7 +8,7 @@
#pragma once
-#include <stddef.h> // for size_t
+#include "dsystem.h" // for size_t
#if __APPLE__ && __i386__
/* size_t is 'unsigned long', which makes it mangle differently
diff --git a/gcc/d/dmd/root/rootobject.c b/gcc/d/dmd/root/rootobject.c
index cd239d6..b45e795 100644
--- a/gcc/d/dmd/root/rootobject.c
+++ b/gcc/d/dmd/root/rootobject.c
@@ -5,8 +5,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/object.c
*/
-#include <stdio.h>
-
+#include "dsystem.h"
#include "object.h"
#include "outbuffer.h"
diff --git a/gcc/d/dmd/root/speller.c b/gcc/d/dmd/root/speller.c
index 52b4e47..a5c16ba 100644
--- a/gcc/d/dmd/root/speller.c
+++ b/gcc/d/dmd/root/speller.c
@@ -6,16 +6,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/speller.c
*/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <limits.h>
-
-#if __sun || _MSC_VER
-#include <alloca.h>
-#endif
-
+#include "dsystem.h"
#include "speller.h"
const char idchars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
diff --git a/gcc/d/dmd/root/stringtable.c b/gcc/d/dmd/root/stringtable.c
index 158e2af..473df7c 100644
--- a/gcc/d/dmd/root/stringtable.c
+++ b/gcc/d/dmd/root/stringtable.c
@@ -6,11 +6,7 @@
* https://github.com/D-Programming-Language/dmd/blob/master/src/root/stringtable.c
*/
-#include <stdio.h>
-#include <stdint.h> // uint{8|16|32}_t
-#include <string.h> // memcpy()
-#include <stdlib.h>
-
+#include "dsystem.h" // uint{8|16|32}_t, memcpy()
#include "root.h"
#include "rmem.h" // mem
#include "stringtable.h"