changeset 538:8a73062f934e

Automated merge with http://hg.dsource.org/projects/llvmdc
author Christian Kamm <kamm incasoftware de>
date Sun, 24 Aug 2008 17:02:03 +0200
parents 2fe2d4518618 (current diff) bfbd71f60572 (diff)
children 795e972e17ce 1c7220171d41
files
diffstat 14 files changed, 107 insertions(+), 87 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/attrib.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/attrib.c	Sun Aug 24 17:02:03 2008 +0200
@@ -14,7 +14,7 @@
 
 #if _WIN32 || IN_GCC || IN_LLVM
 #include "mem.h"
-#elif linux
+#elif linux || __APPLE__
 #include "../root/mem.h"
 #endif
 
--- a/dmd/doc.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/doc.c	Sun Aug 24 17:02:03 2008 +0200
@@ -21,7 +21,7 @@
 #else
 #if _WIN32
 #include "..\root\mem.h"
-#elif linux
+#elif linux || __APPLE__
 #include "../root/mem.h"
 #else
 #error "fix this"
--- a/dmd/expression.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/expression.c	Sun Aug 24 17:02:03 2008 +0200
@@ -25,6 +25,12 @@
 #endif
 #endif
 
+#ifdef __APPLE__
+#ifndef isnan
+int isnan(double);
+#endif
+#endif
+
 #if IN_GCC
 // Issues with using -include total.h (defines integer_t) and then complex.h fails...
 #undef integer_t
@@ -38,7 +44,7 @@
 #include "mem.h"
 #elif _WIN32
 #include "..\root\mem.h"
-#elif linux
+#elif linux || __APPLE__
 #include "../root/mem.h"
 #endif
 
--- a/dmd/hdrgen.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/hdrgen.c	Sun Aug 24 17:02:03 2008 +0200
@@ -29,7 +29,7 @@
 #else
 #if _WIN32
 #include "..\root\mem.h"
-#elif linux
+#elif linux || __APPLE__
 #include "../root/mem.h"
 #else
 #error "fix this"
--- a/dmd/inifile.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/inifile.c	Sun Aug 24 17:02:03 2008 +0200
@@ -79,7 +79,7 @@
 		filename = FileName::replaceName(argv0, inifile);
 		if (!FileName::exists(filename))
 		{
-#if linux
+#if linux || __APPLE__
 
 #if 0
 #if __GLIBC__	    // This fix by Thomas Kuehne
--- a/dmd/macro.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/macro.c	Sun Aug 24 17:02:03 2008 +0200
@@ -21,7 +21,7 @@
 #else
 #if _WIN32
 #include "..\root\mem.h"
-#elif linux
+#elif linux || __APPLE__
 #include "../root/mem.h"
 #else
 #error "fix this"
--- a/dmd/man.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/man.c	Sun Aug 24 17:02:03 2008 +0200
@@ -26,7 +26,7 @@
 
 #endif
 
-#if linux
+#if linux || __APPLE__
 
 #include	<sys/types.h>
 #include	<sys/wait.h>
--- a/dmd/mars.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/mars.c	Sun Aug 24 17:02:03 2008 +0200
@@ -19,7 +19,7 @@
 #include <dos.h>
 #endif
 
-#if linux
+#if linux || __APPLE__
 #include <errno.h>
 #elif _WIN32
 #include <windows.h>
@@ -60,7 +60,7 @@
     bc_ext  = "bc";
 #if _WIN32
     nativeobj_ext = "obj";
-#elif linux
+#elif linux || __APPLE__
     nativeobj_ext = "o";
 #else
 #error "fix this"
@@ -231,9 +231,6 @@
     Module *m;
     int status = EXIT_SUCCESS;
     int argcstart = argc;
-    char* tt_arch = 0;
-    char* tt_os = 0;
-    char* data_layout = 0;
     bool very_verbose = false;
 
     // Check for malformed input
@@ -312,30 +309,23 @@
     VersionCondition::addPredefinedGlobalIdent("LLVMDC");
 #endif
 
+    // setup default target os to be build os
 #if _WIN32
-    VersionCondition::addPredefinedGlobalIdent("Windows");
-    VersionCondition::addPredefinedGlobalIdent("Win32");
-    VersionCondition::addPredefinedGlobalIdent("mingw32");
-    global.params.isWindows = 1;
-    tt_os = "-pc-mingw32";
+    global.params.os = OSWindows;
 #elif linux
-    VersionCondition::addPredefinedGlobalIdent("linux");
-    global.params.isLinux = 1;
-    tt_os = "-pc-linux-gnu";
+    global.params.os = OSLinux;
+#elif __APPLY__
+    global.params.os = OSMacOSX;
 #else
 #error
 #endif /* linux */
 
-    // !win32 == posix for now
-    if (!global.params.isWindows)
-        VersionCondition::addPredefinedGlobalIdent("Posix");
-
     //VersionCondition::addPredefinedGlobalIdent("D_Bits");
     VersionCondition::addPredefinedGlobalIdent("all");
 
 #if _WIN32
     inifile(global.params.argv0, "llvmdc.ini");
-#elif linux
+#elif linux || __APPLE__
     inifile(global.params.argv0, "llvmdc.conf");
 #else
 #error
@@ -700,8 +690,8 @@
         global.params.isLE = true;
         global.params.is64bit = false;
         global.params.cpu = ARCHx86;
-        tt_arch = "i686";
-        data_layout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-f80:32:32-v64:64:64-v128:128:128-a0:0:64";
+        global.params.tt_arch = "i686";
+        global.params.data_layout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-f80:32:32-v64:64:64-v128:128:128-a0:0:64";
         if (global.params.useInlineAsm) {
             VersionCondition::addPredefinedGlobalIdent("D_InlineAsm");
             VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86");
@@ -712,24 +702,24 @@
         global.params.isLE = true;
         global.params.is64bit = true;
         global.params.cpu = ARCHx86_64;
-        tt_arch = "x86_64";
-        data_layout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64";
+        global.params.tt_arch = "x86_64";
+        global.params.data_layout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64";
     }
     else if (strcmp(global.params.llvmArch,"ppc32")==0) {
         VersionCondition::addPredefinedGlobalIdent("PPC");
         global.params.isLE = false;
         global.params.is64bit = false;
         global.params.cpu = ARCHppc;
-        tt_arch = "powerpc";
-        data_layout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64";
+        global.params.tt_arch = "powerpc";
+        global.params.data_layout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64";
     }
     else if (strcmp(global.params.llvmArch,"ppc64")==0) {
         VersionCondition::addPredefinedGlobalIdent("PPC64");
         global.params.isLE = false;
         global.params.is64bit = true;
         global.params.cpu = ARCHppc_64;
-        tt_arch = "powerpc64";
-        data_layout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64";
+        global.params.tt_arch = "powerpc64";
+        global.params.data_layout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64";
     }
     else {
         assert(0 && "Invalid arch");
@@ -750,12 +740,31 @@
         VersionCondition::addPredefinedGlobalIdent("LLVM64");
     }
 
-    assert(tt_arch != 0);
-    assert(tt_os != 0);
-    assert(data_layout != 0);
-    global.params.tt_arch = tt_arch;
-    global.params.tt_os = tt_os;
-    global.params.data_layout = data_layout;
+
+    // setup version idents and tt_os for chosen target os
+    switch(global.params.os)
+    {
+    case OSWindows:
+	VersionCondition::addPredefinedGlobalIdent("Windows");
+	VersionCondition::addPredefinedGlobalIdent("Win32");
+	VersionCondition::addPredefinedGlobalIdent("mingw32");
+	global.params.tt_os = "-pc-mingw32";
+	break;
+
+    case OSLinux:
+	VersionCondition::addPredefinedGlobalIdent("linux");
+	VersionCondition::addPredefinedGlobalIdent("Posix");
+	global.params.tt_os = "-pc-linux-gnu";
+	break;
+
+    case OSMacOSX:
+	VersionCondition::addPredefinedGlobalIdent("darwin");
+	global.params.tt_os = "-pc-darwin-gnu";
+
+    default:
+	assert(false && "Target OS not supported");
+    }
+
 
     // Initialization
     Type::init();
--- a/dmd/mars.h	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/mars.h	Sun Aug 24 17:02:03 2008 +0200
@@ -37,6 +37,22 @@
 
 struct Array;
 
+// LLVMDC
+enum ARCH
+{
+    ARCHx86,
+    ARCHx86_64,
+    ARCHppc,
+    ARCHppc_64
+};
+
+enum OS
+{
+    OSLinux,
+    OSWindows,
+    OSMacOSX
+};
+
 // Put command line switches in here
 struct Param
 {
@@ -48,11 +64,10 @@
     char symdebug;	// insert debug symbolic information
     char optimize;	// run optimizer
     char optimizeLevel; // optimization level
-    char cpu;		// target CPU
+    ARCH cpu;		// target CPU
+    OS   os;		// target OS
     char is64bit;	// generate 64 bit code
     char isLE;      // generate little endian code
-    char isLinux;	// generate code for linux
-    char isWindows;	// generate code for Windows
     char scheduler;	// which scheduler to use
     char useDeprecated;	// allow use of deprecated features
     char useAssert;	// generate runtime code for assert()'s
@@ -305,15 +320,6 @@
     MATCHexact		// exact match
 };
 
-// LLVMDC
-enum ARCH
-{
-    ARCHx86,
-    ARCHx86_64,
-    ARCHppc,
-    ARCHppc_64
-};
-
 void error(Loc loc, const char *format, ...);
 void verror(Loc loc, const char *format, va_list);
 void fatal();
--- a/dmd/opover.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/opover.c	Sun Aug 24 17:02:03 2008 +0200
@@ -20,7 +20,7 @@
 
 #if IN_GCC || IN_LLVM
 #include "mem.h"
-#elif linux
+#elif linux || __APPLE__
 #include "../root/mem.h"
 #elif _WIN32
 #include "..\root\mem.h"
--- a/dmd/root.c	Sun Aug 24 16:51:17 2008 +0200
+++ b/dmd/root.c	Sun Aug 24 17:02:03 2008 +0200
@@ -23,7 +23,7 @@
 #include <direct.h>
 #endif
 
-#if linux
+#if linux || __APPLE__
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -370,13 +370,13 @@
 			instring ^= 1;	// toggle inside/outside of string
 			continue;
 
-#if MACINTOSH
+/*#if MACINTOSH
 		    case ',':
-#endif
+#endif*/
 #if _WIN32
 		    case ';':
 #endif
-#if linux
+#if linux || __APPLE__
 		    case ':':
 #endif
 			p++;
@@ -390,7 +390,7 @@
 		    case '\r':
 			continue;	// ignore carriage returns
 
-#if linux
+#if linux || __APPLE__
 		    case '~':
 			buf.writestring(getenv("HOME"));
 			continue;
@@ -714,7 +714,7 @@
 	return 1;
     if (!e || !ext)
 	return 0;
-#if linux
+#if linux || __APPLE__
     return strcmp(e,ext) == 0;
 #endif
 #if _WIN32
@@ -733,7 +733,7 @@
 #if _WIN32
     file.touchtime = mem.malloc(sizeof(WIN32_FIND_DATAA));	// keep same file time
 #endif
-#if linux
+#if linux || __APPLE__
     file.touchtime = mem.malloc(sizeof(struct stat)); // keep same file time
 #endif
     file.readv();
@@ -775,7 +775,7 @@
 
 int FileName::exists(const char *name)
 {
-#if linux
+#if linux || __APPLE__
     struct stat st;
 
     if (stat(name, &st) < 0)
@@ -822,7 +822,7 @@
 #if _WIN32
 	    if (path[strlen(path) - 1] != '\\')
 #endif
-#if linux
+#if linux || __APPLE__
 	    if (path[strlen(path) - 1] != '\\')
 #endif
 	    {
@@ -830,7 +830,7 @@
 #if _WIN32
 		if (mkdir(path))
 #endif
-#if linux
+#if linux || __APPLE__
 		if (mkdir(path, 0777))
 #endif
 		    error("cannot create directory %s", path);
@@ -886,7 +886,7 @@
 
 int File::read()
 {
-#if linux
+#if linux || __APPLE__
     off_t size;
     ssize_t numread;
     int fd;
@@ -1018,7 +1018,7 @@
 
 int File::mmread()
 {
-#if linux
+#if linux || __APPLE__
     return read();
 #endif
 #if _WIN32
@@ -1072,7 +1072,7 @@
 
 int File::write()
 {
-#if linux
+#if linux || __APPLE__
     int fd;
     ssize_t numwritten;
     char *name;
@@ -1145,7 +1145,7 @@
 
 int File::append()
 {
-#if linux
+#if linux || __APPLE__
     return 1;
 #endif
 #if _WIN32
@@ -1225,7 +1225,7 @@
 
 int File::exists()
 {
-#if linux
+#if linux || __APPLE__
     return 0;
 #endif
 #if _WIN32
@@ -1250,7 +1250,7 @@
 
 void File::remove()
 {
-#if linux
+#if linux || __APPLE__
     ::remove(this->name->toChars());
 #endif
 #if _WIN32
@@ -1265,7 +1265,7 @@
 
 Array *File::match(FileName *n)
 {
-#if linux
+#if linux || __APPLE__
     return NULL;
 #endif
 #if _WIN32
@@ -1303,7 +1303,7 @@
 
 int File::compareTime(File *f)
 {
-#if linux
+#if linux || __APPLE__
     return 0;
 #endif
 #if _WIN32
@@ -1317,7 +1317,7 @@
 
 void File::stat()
 {
-#if linux
+#if linux || __APPLE__
     if (!touchtime)
     {
 	touchtime = mem.calloc(1, sizeof(struct stat));
@@ -1622,7 +1622,7 @@
 	    break;
 	psize *= 2;
 #endif
-#if linux
+#if linux || __APPLE__
 	count = vsnprintf(p,psize,format,args);
 	if (count == -1)
 	    psize *= 2;
@@ -1654,7 +1654,7 @@
 	    break;
 	psize *= 2;
 #endif
-#if linux
+#if linux || __APPLE__
 	count = vsnwprintf(p,psize,format,args);
 	if (count == -1)
 	    psize *= 2;
--- a/gen/linker.cpp	Sun Aug 24 16:51:17 2008 +0200
+++ b/gen/linker.cpp	Sun Aug 24 17:02:03 2008 +0200
@@ -72,7 +72,7 @@
         else
             exestr = "a.out";
     }
-    if (global.params.isWindows)
+    if (global.params.os == OSWindows)
         exestr.append(".exe");
 
     std::string outopt = "-o=" + exestr;
@@ -151,13 +151,13 @@
     }
 
     // default libs
-    if(global.params.isLinux)
+    if(global.params.os == OSLinux)
     {
         args.push_back("-lpthread");
         args.push_back("-ldl");
         args.push_back("-lm");
     }
-    else if (global.params.isWindows)
+    else if (global.params.os == OSWindows)
     {
         // FIXME: I'd assume kernel32 etc
     }
@@ -174,12 +174,11 @@
     std::string runtime_path(global.params.runtimePath);
 
     // path seperator can be \ on windows, but we check for /
-    if (global.params.isWindows)
-    {
-        int i=0;
-        while ((i = runtime_path.find("\\", i)) > 0)
-            runtime_path.replace(i, 1, "/");
-    }
+#if _WIN32
+    int i=0;
+    while ((i = runtime_path.find("\\", i)) > 0)
+        runtime_path.replace(i, 1, "/");
+#endif
 
     if (*runtime_path.rbegin() != '/')
         runtime_path.append("/");
--- a/gen/tollvm.cpp	Sun Aug 24 16:51:17 2008 +0200
+++ b/gen/tollvm.cpp	Sun Aug 24 17:02:03 2008 +0200
@@ -705,7 +705,7 @@
         return gIR->mutexType;
 
     // win32
-    if (global.params.isWindows)
+    if (global.params.os == OSWindows)
     {
         // CRITICAL_SECTION.sizeof == 68
         std::vector<const LLType*> types(17, LLType::Int32Ty);
--- a/runtime/build.sh	Sun Aug 24 16:51:17 2008 +0200
+++ b/runtime/build.sh	Sun Aug 24 17:02:03 2008 +0200
@@ -4,12 +4,12 @@
 
 # copy imports
 mkdir -p ../tango/llvmdc
-cp -u internal/llvmdc/bitmanip.d ../tango/llvmdc/bitmanip.di
-cp -u internal/llvmdc/vararg.d ../tango/llvmdc/vararg.di
-cp -u import/llvmdc/* ../tango/llvmdc
+cp internal/llvmdc/bitmanip.d ../tango/llvmdc/bitmanip.di
+cp internal/llvmdc/vararg.d ../tango/llvmdc/vararg.di
+cp import/llvmdc/* ../tango/llvmdc
 
 # make the runtime
-cp -Ru lib ../tango
+cp -R lib ../tango
 cd ../tango/lib
 make -f llvmdc-posix.mak clean
 make -f llvmdc-posix.mak