# HG changeset patch
# Parent 0f6ccc9cfd024f705876c70a6403268ea9dbf0a2
Fix D compilation on Solaris
diff --git a/gcc/config.gcc b/gcc/config.gcc
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -918,6 +918,7 @@ case ${target} in
target_gtfiles="$target_gtfiles \$(srcdir)/config/sol2.c"
c_target_objs="${c_target_objs} sol2-c.o"
cxx_target_objs="${cxx_target_objs} sol2-c.o sol2-cxx.o"
+ d_target_objs="${d_target_objs} sol2-d.o"
extra_objs="${extra_objs} sol2.o sol2-stubs.o"
extra_options="${extra_options} sol2.opt"
case ${enable_threads}:${have_pthread_h}:${have_thread_h} in
@@ -925,6 +926,7 @@ case ${target} in
thread_file=posix
;;
esac
+ target_has_targetdm=yes
;;
*-*-*vms*)
extra_options="${extra_options} vms/vms.opt"
diff --git a/gcc/config/default-d.c b/gcc/config/default-d.c
--- a/gcc/config/default-d.c
+++ b/gcc/config/default-d.c
@@ -18,6 +18,7 @@ along with GCC; see the file COPYING3.
#include "config.h"
#include "system.h"
#include "coretypes.h"
+#include "memmodel.h"
#include "tm_d.h"
#include "d/d-target.h"
#include "d/d-target-def.h"
diff --git a/gcc/config/sol2-d.c b/gcc/config/sol2-d.c
new file mode 100644
--- /dev/null
+++ b/gcc/config/sol2-d.c
@@ -0,0 +1,51 @@
+/* Solaris support needed only by D front-end.
+ 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
+. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "memmodel.h"
+#include "tm_p.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_OS_VERSIONS for Solaris targets. */
+
+static void
+solaris_d_os_builtins (void)
+{
+ d_add_builtin_version ("Posix");
+ d_add_builtin_version ("Solaris"); \
+}
+
+/* Implement TARGET_D_CRITSEC_SIZE for Solaris targets. */
+
+static unsigned
+solaris_d_critsec_size (void)
+{
+ /* This is the sizeof pthread_mutex_t. */
+ return 24;
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS solaris_d_os_builtins
+
+#undef TARGET_D_CRITSEC_SIZE
+#define TARGET_D_CRITSEC_SIZE solaris_d_critsec_size
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
diff --git a/gcc/config/t-sol2 b/gcc/config/t-sol2
--- a/gcc/config/t-sol2
+++ b/gcc/config/t-sol2
@@ -16,7 +16,7 @@
# along with GCC; see the file COPYING3. If not see
# .
-# Solaris-specific format checking and pragmas
+# Solaris-specific format checking and pragmas.
sol2-c.o: $(srcdir)/config/sol2-c.c
$(COMPILE) $<
$(POSTCOMPILE)
@@ -26,6 +26,11 @@ sol2-cxx.o: $(srcdir)/config/sol2-cxx.c
$(COMPILE) $<
$(POSTCOMPILE)
+# Solaris-specific D support.
+sol2-d.o: $(srcdir)/config/sol2-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
# Corresponding stub routines.
sol2-stubs.o: $(srcdir)/config/sol2-stubs.c
$(COMPILE) $<
diff --git a/gcc/d/dmd/expression.h b/gcc/d/dmd/expression.h
--- a/gcc/d/dmd/expression.h
+++ b/gcc/d/dmd/expression.h
@@ -1509,7 +1509,7 @@ private:
char sliceexp [sizeof(SliceExp)];
// Ensure that the union is suitably aligned.
- real_t for_alignment_only;
+ long double for_alignment_only;
} u;
};
diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d
--- a/libphobos/libdruntime/core/stdc/fenv.d
+++ b/libphobos/libdruntime/core/stdc/fenv.d
@@ -33,6 +33,16 @@ version (PPC)
else version (PPC64)
version = PPC_Any;
+version (SPARC)
+ version = SPARC_Any;
+version (SPARC64)
+ version = SPARC_Any;
+
+version (X86)
+ version = X86_Any;
+version (X86_64)
+ version = X86_Any;
+
version (MinGW)
version = GNUFP;
version (CRuntime_Glibc)
@@ -451,6 +461,50 @@ version (CRuntime_Microsoft)
FE_TOWARDZERO = 0x300, ///
}
}
+else version (Solaris)
+{
+ version (SPARC_Any)
+ {
+ enum
+ {
+ FE_TONEAREST = 0,
+ FE_TOWARDZERO = 1,
+ FE_UPWARD = 2,
+ FE_DOWNWARD = 3,
+ }
+
+ enum
+ {
+ FE_INEXACT = 0x01,
+ FE_DIVBYZERO = 0x02,
+ FE_UNDERFLOW = 0x04,
+ FE_OVERFLOW = 0x08,
+ FE_INVALID = 0x10,
+ FE_ALL_EXCEPT = 0x1f,
+ }
+
+ }
+ else version (X86_Any)
+ {
+ enum
+ {
+ FE_TONEAREST = 0,
+ FE_DOWNWARD = 1,
+ FE_UPWARD = 2,
+ FE_TOWARDZERO = 3,
+ }
+
+ enum
+ {
+ FE_INVALID = 0x01,
+ FE_DIVBYZERO = 0x04,
+ FE_OVERFLOW = 0x08,
+ FE_UNDERFLOW = 0x10,
+ FE_INEXACT = 0x20,
+ FE_ALL_EXCEPT = 0x3d,
+ }
+ }
+}
else
{
version (X86)
diff --git a/libphobos/libdruntime/core/sys/posix/aio.d b/libphobos/libdruntime/core/sys/posix/aio.d
--- a/libphobos/libdruntime/core/sys/posix/aio.d
+++ b/libphobos/libdruntime/core/sys/posix/aio.d
@@ -123,6 +123,32 @@ else version (DragonFlyBSD)
version = BSD_Posix;
}
+else version (Solaris)
+{
+ struct aio_result_t
+ {
+ ssize_t aio_return;
+ int aio_errno;
+ };
+
+ struct aiocb
+ {
+ int aio_fildes;
+ void* aio_buf; // volatile
+ size_t aio_nbytes;
+ off_t aio_offset;
+ int aio_reqprio;
+ sigevent aio_sigevent;
+ int aio_lio_opcode;
+ aio_result_t aio_result;
+ byte aio_state;
+ byte aio_returned;
+ byte[2] aio__pad1;
+ int aio_flags;
+ }
+
+ version = BSD_Posix;
+}
else
static assert(false, "Unsupported platform");
diff --git a/libphobos/libdruntime/core/sys/posix/ucontext.d b/libphobos/libdruntime/core/sys/posix/ucontext.d
--- a/libphobos/libdruntime/core/sys/posix/ucontext.d
+++ b/libphobos/libdruntime/core/sys/posix/ucontext.d
@@ -937,7 +937,17 @@ else version (Solaris)
{
alias uint[4] upad128_t;
- version (X86_64)
+ version (SPARC64)
+ {
+ enum _NGREG = 21;
+ alias long greg_t;
+ }
+ else version (SPARC)
+ {
+ enum _NGREG = 19;
+ alias int greg_t;
+ }
+ else version (X86_64)
{
enum _NGREG = 28;
alias long greg_t;
@@ -950,7 +960,70 @@ else version (Solaris)
alias greg_t[_NGREG] gregset_t;
- version (X86_64)
+ version (SPARC64)
+ {
+ struct _fpq
+ {
+ uint *fpq_addr;
+ uint fpq_instr;
+ }
+
+ struct fq
+ {
+ union
+ {
+ double whole;
+ _fpq fpq;
+ };
+ }
+
+ struct fpregset_t
+ {
+ union
+ {
+ uint[32] fpu_regs;
+ double[32] fpu_dregs;
+ real[16] fpu_qregs;
+ };
+ fq *fpu_q;
+ ulong fpu_fsr;
+ ubyte fpu_qcnt;
+ ubyte fpu_q_entrysize;
+ ubyte fpu_en;
+ }
+ }
+ else version (SPARC)
+ {
+ struct _fpq
+ {
+ uint *fpq_addr;
+ uint fpq_instr;
+ }
+
+ struct fq
+ {
+ union
+ {
+ double whole;
+ _fpq fpq;
+ };
+ }
+
+ struct fpregset_t
+ {
+ union
+ {
+ uint[32] fpu_regs;
+ double[16] fpu_dregs;
+ };
+ fq *fpu_q;
+ uint fpu_fsr;
+ ubyte fpu_qcnt;
+ ubyte fpu_q_entrysize;
+ ubyte fpu_en;
+ }
+ }
+ else version (X86_64)
{
union _u_st
{
diff --git a/libphobos/libdruntime/core/thread.d b/libphobos/libdruntime/core/thread.d
--- a/libphobos/libdruntime/core/thread.d
+++ b/libphobos/libdruntime/core/thread.d
@@ -1547,7 +1547,7 @@ private:
version (Solaris)
{
- __gshared immutable bool m_isRTClass;
+ __gshared bool m_isRTClass;
}
private:
diff --git a/libphobos/libdruntime/rt/sections_solaris.d b/libphobos/libdruntime/rt/sections_solaris.d
--- a/libphobos/libdruntime/rt/sections_solaris.d
+++ b/libphobos/libdruntime/rt/sections_solaris.d
@@ -34,7 +34,7 @@ struct SectionGroup
return _moduleGroup.modules;
}
- @property ref inout(ModuleGroup) moduleGroup() inout
+ @property ref inout(ModuleGroup) moduleGroup() inout nothrow @nogc
{
return _moduleGroup;
}
@@ -87,6 +87,24 @@ void scanTLSRanges(void[] rng, scope voi
dg(rng.ptr, rng.ptr + rng.length);
}
+// interface for core.thread to inherit loaded libraries
+void* pinLoadedLibraries() nothrow @nogc
+{
+ return null;
+}
+
+void unpinLoadedLibraries(void* p) nothrow @nogc
+{
+}
+
+void inheritLoadedLibraries(void* p) nothrow @nogc
+{
+}
+
+void cleanupLoadedLibraries() nothrow @nogc
+{
+}
+
private:
__gshared SectionGroup _sections;
diff --git a/libphobos/src/std/datetime/systime.d b/libphobos/src/std/datetime/systime.d
--- a/libphobos/src/std/datetime/systime.d
+++ b/libphobos/src/std/datetime/systime.d
@@ -221,6 +221,7 @@ public:
else
{
import core.sys.solaris.time : CLOCK_REALTIME;
+ import core.sys.posix.time : clock_gettime;
static if (clockType == ClockType.coarse) alias clockArg = CLOCK_REALTIME;
else static if (clockType == ClockType.normal) alias clockArg = CLOCK_REALTIME;
else static if (clockType == ClockType.precise) alias clockArg = CLOCK_REALTIME;
diff --git a/libphobos/src/std/math.d b/libphobos/src/std/math.d
--- a/libphobos/src/std/math.d
+++ b/libphobos/src/std/math.d
@@ -160,6 +160,8 @@ version (MIPS32) version = MIPS_Any;
version (MIPS64) version = MIPS_Any;
version (AArch64) version = ARM_Any;
version (ARM) version = ARM_Any;
+version (SPARC) version = SPARC_Any;
+version (SPARC64) version = SPARC_Any;
version (D_InlineAsm_X86)
{
@@ -5161,7 +5163,7 @@ struct FloatingPointControl
| inexactException,
}
}
- else version (SPARC64)
+ else version (SPARC_Any)
{
enum : ExceptionMask
{
@@ -5291,7 +5293,7 @@ private:
{
alias ControlState = uint;
}
- else version (SPARC64)
+ else version (SPARC_Any)
{
alias ControlState = ulong;
}