diff mbox series

[libphobos] Committed added druntime bindings for sparc/solaris

Message ID CABOHX+dQExaR_5oZndwK6bcJebCrmP0mvWrZkFjKbcUVDZDzmg@mail.gmail.com
State New
Headers show
Series [libphobos] Committed added druntime bindings for sparc/solaris | expand

Commit Message

Iain Buclaw Dec. 9, 2018, 11:49 p.m. UTC
Hi,

This patch is backported from druntime master, adding initial
libdruntime bindings support for SPARC/Solaris.  Though I suspect
there's still plenty that's been missed out.

Bootstrapped and tested on x86_64-linux-gnu, not that it checks
anything except all changes are properly scoped.

Committed to trunk as r266935.
diff mbox series

Patch

diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d
index 00b99af97a2..abfdcde5330 100644
--- a/libphobos/libdruntime/core/stdc/fenv.d
+++ b/libphobos/libdruntime/core/stdc/fenv.d
@@ -457,6 +457,54 @@  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
+    {
+        static assert(0, "Unimplemented architecture");
+    }
+}
 else
 {
     version (X86)
diff --git a/libphobos/libdruntime/core/sys/posix/aio.d b/libphobos/libdruntime/core/sys/posix/aio.d
index 372152ab063..99bd0b3475b 100644
--- a/libphobos/libdruntime/core/sys/posix/aio.d
+++ b/libphobos/libdruntime/core/sys/posix/aio.d
@@ -123,15 +123,58 @@  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_resultp;
+        int aio_state;
+        int[1] aio__pad;
+    }
+}
 else
     static assert(false, "Unsupported platform");
 
 /* Return values of cancelation function.  */
-enum
+version (CRuntime_Glibc)
 {
-    AIO_CANCELED,
-    AIO_NOTCANCELED,
-    AIO_ALLDONE
+    enum
+    {
+        AIO_CANCELED,
+        AIO_NOTCANCELED,
+        AIO_ALLDONE
+    }
+}
+else version (Solaris)
+{
+    enum
+    {
+        AIO_CANCELED,
+        AIO_ALLDONE,
+        AIO_NOTCANCELED
+    }
+}
+else version (BSD_Posix)
+{
+    enum
+    {
+        AIO_CANCELED,
+        AIO_NOTCANCELED,
+        AIO_ALLDONE
+    }
 }
 
 /* Operation codes for `aio_lio_opcode'.  */
@@ -144,6 +187,15 @@  version (CRuntime_Glibc)
         LIO_NOP
     }
 }
+else version (Solaris)
+{
+    enum
+    {
+        LIO_NOP,
+        LIO_READ,
+        LIO_WRITE,
+    }
+}
 else version (BSD_Posix)
 {
     enum
@@ -163,6 +215,14 @@  version (CRuntime_Glibc)
         LIO_NOWAIT
     }
 }
+else version (Solaris)
+{
+    enum
+    {
+        LIO_NOWAIT,
+        LIO_WAIT
+    }
+}
 else version (BSD_Posix)
 {
     enum
diff --git a/libphobos/libdruntime/core/sys/posix/ucontext.d b/libphobos/libdruntime/core/sys/posix/ucontext.d
index 964b77cc50d..9e7d6436e7e 100644
--- a/libphobos/libdruntime/core/sys/posix/ucontext.d
+++ b/libphobos/libdruntime/core/sys/posix/ucontext.d
@@ -989,7 +989,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;
@@ -999,10 +1009,81 @@  else version (Solaris)
         enum _NGREG = 19;
         alias int greg_t;
     }
+    else
+        static assert(0, "unimplemented");
 
     alias greg_t[_NGREG] gregset_t;
 
-    version (X86_64)
+    version (SPARC64)
+    {
+        private
+        {
+            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)
+    {
+        private
+        {
+            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
         {
@@ -1063,6 +1144,9 @@  else version (Solaris)
         u_fp_reg_set fp_reg_set;
         }
     }
+    else
+        static assert(0, "unimplemented");
+
     struct mcontext_t
     {
         gregset_t   gregs;