changeset 872:aa953cc960b6

Apply BlueZeniX's patch for OpenSolaris compatibility. Fixes #158.
author Christian Kamm <kamm incasoftware de>
date Sun, 04 Jan 2009 15:49:28 +0100
parents e70a0e7e2260
children a331ce9bc749
files dmd/array.c dmd/inifile.c dmd/lexer.c dmd/mars.c dmd/mars.h dmd/module.c dmd/mtype.c dmd/root.c runtime/internal/critical.c runtime/internal/eh.d runtime/internal/memory.d runtime/internal/monitor.c
diffstat 12 files changed, 57 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/array.c	Sun Jan 04 15:39:34 2009 +0100
+++ b/dmd/array.c	Sun Jan 04 15:49:28 2009 +0100
@@ -13,6 +13,10 @@
 #include <string.h>
 #include <assert.h>
 
+#if (defined (__SVR4) && defined (__sun)) 
+#include <alloca.h>
+#endif
+
 #if _MSC_VER || __MINGW32__
 #include <malloc.h>
 #endif
--- a/dmd/inifile.c	Sun Jan 04 15:39:34 2009 +0100
+++ b/dmd/inifile.c	Sun Jan 04 15:49:28 2009 +0100
@@ -10,6 +10,10 @@
 #include	<stdlib.h>
 #include	<ctype.h>
 
+#if (defined (__SVR4) && defined (__sun))
+#include <alloca.h>
+#endif
+
 #include	"root.h"
 #include	"mem.h"
 
--- a/dmd/lexer.c	Sun Jan 04 15:39:34 2009 +0100
+++ b/dmd/lexer.c	Sun Jan 04 15:49:28 2009 +0100
@@ -8,6 +8,8 @@
 // in artistic.txt, or the GNU General Public License in gnu.txt.
 // See the included readme.txt for details.
 
+#define __C99FEATURES__ 1
+
 /* Lexical Analyzer */
 
 #include <stdio.h>
--- a/dmd/mars.c	Sun Jan 04 15:39:34 2009 +0100
+++ b/dmd/mars.c	Sun Jan 04 15:49:28 2009 +0100
@@ -338,8 +338,10 @@
     global.params.os = OSMacOSX;
 #elif __FreeBSD__
     global.params.os = OSFreeBSD;
+#elif defined (__SVR4) && defined (__sun)
+    global.params.os = OSSolaris;
 #else
-#error Unsupported OS
+ #error Unsupported OS
 #endif /* linux */
 
     assert(global.params.os != OSinvalid);
@@ -694,6 +696,8 @@
                 global.params.os = OSMacOSX;
             else if(strcmp(p + 2, "FreeBSD") == 0)
                 global.params.os = OSFreeBSD;
+            else if(strcmp(p + 2, "Solaris") == 0)
+                global.params.os = OSSolaris;
             else
                 error("unrecognized target os '%s'", p + 2);
         }
@@ -929,6 +933,11 @@
     VersionCondition::addPredefinedGlobalIdent("Posix");
     break;
 
+    case OSSolaris:
+    VersionCondition::addPredefinedGlobalIdent("solaris");
+    VersionCondition::addPredefinedGlobalIdent("Posix");
+    break;
+
     default:
 	assert(false && "Target OS not supported");
     }
--- a/dmd/mars.h	Sun Jan 04 15:39:34 2009 +0100
+++ b/dmd/mars.h	Sun Jan 04 15:49:28 2009 +0100
@@ -61,7 +61,8 @@
     OSLinux,
     OSWindows,
     OSMacOSX,
-    OSFreeBSD
+    OSFreeBSD,
+    OSSolaris,
 };
 
 // Put command line switches in here
--- a/dmd/module.c	Sun Jan 04 15:39:34 2009 +0100
+++ b/dmd/module.c	Sun Jan 04 15:49:28 2009 +0100
@@ -12,6 +12,10 @@
 #include <stdlib.h>
 #include <assert.h>
 
+#if (defined (__SVR4) && defined (__sun))
+#include <alloca.h>
+#endif
+
 #if _MSC_VER || __MINGW32__
 #include <malloc.h>
 #endif
--- a/dmd/mtype.c	Sun Jan 04 15:39:34 2009 +0100
+++ b/dmd/mtype.c	Sun Jan 04 15:49:28 2009 +0100
@@ -8,7 +8,13 @@
 // in artistic.txt, or the GNU General Public License in gnu.txt.
 // See the included readme.txt for details.
 
+#define __C99FEATURES__ 1	// Needed on Solaris for NaN and more
 #define __USE_ISOC99 1		// so signbit() gets defined
+
+#if (defined (__SVR4) && defined (__sun))
+#include <alloca.h>
+#endif
+
 #include <math.h>
 
 #include <stdio.h>
--- a/dmd/root.c	Sun Jan 04 15:39:34 2009 +0100
+++ b/dmd/root.c	Sun Jan 04 15:49:28 2009 +0100
@@ -14,6 +14,10 @@
 #include <stdint.h>
 #include <assert.h>
 
+#if (defined (__SVR4) && defined (__sun))
+#include <alloca.h>
+#endif
+
 #if _MSC_VER ||__MINGW32__
 #include <malloc.h>
 #include <string>
--- a/runtime/internal/critical.c	Sun Jan 04 15:39:34 2009 +0100
+++ b/runtime/internal/critical.c	Sun Jan 04 15:49:28 2009 +0100
@@ -75,7 +75,7 @@
 
 /* ================================= linux ============================ */
 
-#if linux || __APPLE__ || __FreeBSD__
+#if linux || __APPLE__ || __FreeBSD__ || (defined(__SVR4) && defined (__sun))
 
 #include	<stdio.h>
 #include	<stdlib.h>
--- a/runtime/internal/eh.d	Sun Jan 04 15:39:34 2009 +0100
+++ b/runtime/internal/eh.d	Sun Jan 04 15:49:28 2009 +0100
@@ -14,9 +14,11 @@
 version(X86) {
     version(linux) version=X86_UNWIND;
     version(darwin) version=X86_UNWIND;
+    version(solaris) version=X86_UNWIND;
 }
 version(X86_64) {
     version(linux) version=X86_UNWIND;
+    version(solaris) version=X86_UNWIND;
 }
 
 private extern(C) void abort();
--- a/runtime/internal/memory.d	Sun Jan 04 15:39:34 2009 +0100
+++ b/runtime/internal/memory.d	Sun Jan 04 15:49:28 2009 +0100
@@ -73,6 +73,13 @@
 /**
  *
  */
+
+version( solaris ) {	
+    version(X86_64) {
+        extern (C) void* _userlimit;
+    }
+}
+
 extern (C) void* rt_stackBottom()
 {
     version( Win32 )
@@ -110,6 +117,16 @@
         // darwin has a fixed stack bottom
         return cast(void*) 0xc0000000;
     }
+    else version( solaris )
+    {
+        version(X86_64) {
+            return _userlimit;
+        }
+        else {
+            // <sys/vmparam.h>
+            return cast(void*) 0x8048000;
+        }
+    }
     else
     {
         static assert( false, "Operating system not supported." );
--- a/runtime/internal/monitor.c	Sun Jan 04 15:39:34 2009 +0100
+++ b/runtime/internal/monitor.c	Sun Jan 04 15:49:28 2009 +0100
@@ -12,7 +12,7 @@
 #include <assert.h>
 
 #if _WIN32
-#elif linux || __APPLE__
+#elif linux || __APPLE__ || (defined (__SVR4) && defined (__sun))
 #define USE_PTHREADS	1
 #else
 #endif