comparison dmd/mars.c @ 279:a137ed004205 trunk

[svn r300] Removed some win32 stuff that was causing problems on mingw32.
author lindquist
date Fri, 20 Jun 2008 22:25:07 +0200
parents 90a8c798b0db
children 70c370e97944
comparison
equal deleted inserted replaced
278:30941d8ee320 279:a137ed004205
15 #include <ctype.h> 15 #include <ctype.h>
16 #include <assert.h> 16 #include <assert.h>
17 #include <limits.h> 17 #include <limits.h>
18 #include <string> 18 #include <string>
19 #include <cstdarg> 19 #include <cstdarg>
20
21 #if _WIN32
22 #include <windows.h>
23 long __cdecl __ehfilter(LPEXCEPTION_POINTERS ep);
24 #endif
25 20
26 #if __DMC__ 21 #if __DMC__
27 #include <dos.h> 22 #include <dos.h>
28 #endif 23 #endif
29 24
309 304
310 // Predefine version identifiers 305 // Predefine version identifiers
311 #if IN_LLVM 306 #if IN_LLVM
312 VersionCondition::addPredefinedGlobalIdent("LLVM"); 307 VersionCondition::addPredefinedGlobalIdent("LLVM");
313 VersionCondition::addPredefinedGlobalIdent("LLVMDC"); 308 VersionCondition::addPredefinedGlobalIdent("LLVMDC");
314 VersionCondition::addPredefinedGlobalIdent("Posix");
315 #endif 309 #endif
316 #if _WIN32 310 #if _WIN32
317 VersionCondition::addPredefinedGlobalIdent("Windows"); 311 VersionCondition::addPredefinedGlobalIdent("Windows");
318 VersionCondition::addPredefinedGlobalIdent("Win32"); 312 VersionCondition::addPredefinedGlobalIdent("Win32");
313 VersionCondition::addPredefinedGlobalIdent("mingw32");
319 global.params.isWindows = 1; 314 global.params.isWindows = 1;
320 tt_os = "-pc-mingw32"; 315 tt_os = "-pc-mingw32";
321 #elif linux 316 #elif linux
322 VersionCondition::addPredefinedGlobalIdent("linux"); 317 VersionCondition::addPredefinedGlobalIdent("linux");
323 global.params.isLinux = 1; 318 global.params.isLinux = 1;
324 tt_os = "-unknown-linux-gnu"; 319 tt_os = "-pc-linux-gnu";
325 #else 320 #else
326 #error 321 #error
327 #endif /* linux */ 322 #endif /* linux */
323
324 // !win32 == posix for now
325 if (!global.params.isWindows)
326 VersionCondition::addPredefinedGlobalIdent("Posix");
328 327
329 //VersionCondition::addPredefinedGlobalIdent("D_Bits"); 328 //VersionCondition::addPredefinedGlobalIdent("D_Bits");
330 VersionCondition::addPredefinedGlobalIdent("all"); 329 VersionCondition::addPredefinedGlobalIdent("all");
331 330
332 #if _WIN32 331 #if _WIN32
835 char *ext; 834 char *ext;
836 char *name; 835 char *name;
837 836
838 p = (char *) files.data[i]; 837 p = (char *) files.data[i];
839 838
840 #if _WIN32
841 // Convert / to \ so linker will work
842 for (int i = 0; p[i]; i++)
843 {
844 if (p[i] == '/')
845 p[i] = '\\';
846 }
847 #endif
848
849 p = FileName::name(p); // strip path 839 p = FileName::name(p); // strip path
850 ext = FileName::ext(p); 840 ext = FileName::ext(p);
851 if (ext) 841 if (ext)
852 { 842 {
853 #if IN_LLVM 843 #if IN_LLVM
861 { 851 {
862 global.params.objfiles->push(files.data[i]); 852 global.params.objfiles->push(files.data[i]);
863 continue; 853 continue;
864 } 854 }
865 855
866 #if TARGET_LINUX 856 #if TARGET_LINUX || __MINGW32__
867 if (strcmp(ext, "a") == 0) 857 if (strcmp(ext, "a") == 0)
868 #else 858 #else
869 if (stricmp(ext, "lib") == 0) 859 if (stricmp(ext, "lib") == 0)
870 #endif 860 #endif
871 { 861 {
935 modules.push(m); 925 modules.push(m);
936 926
937 global.params.objfiles->push(m->objfile->name->str); 927 global.params.objfiles->push(m->objfile->name->str);
938 } 928 }
939 929
940 #if _WIN32
941 __try
942 {
943 #endif
944 // Read files, parse them 930 // Read files, parse them
945 for (i = 0; i < modules.dim; i++) 931 for (i = 0; i < modules.dim; i++)
946 { 932 {
947 m = (Module *)modules.data[i]; 933 m = (Module *)modules.data[i];
948 if (global.params.verbose) 934 if (global.params.verbose)
1082 { 1068 {
1083 if (global.params.doDocComments) 1069 if (global.params.doDocComments)
1084 m->gendocfile(); 1070 m->gendocfile();
1085 } 1071 }
1086 } 1072 }
1087 #if _WIN32 1073
1088 }
1089 __except (__ehfilter(GetExceptionInformation()))
1090 {
1091 printf("Stack overflow\n");
1092 fatal();
1093 }
1094 #endif
1095 backend_term(); 1074 backend_term();
1096 if (global.errors) 1075 if (global.errors)
1097 fatal(); 1076 fatal();
1098 1077
1099 if (!global.params.objfiles->dim) 1078 if (!global.params.objfiles->dim)
1236 1215
1237 Ldone: 1216 Ldone:
1238 *pargc = argc; 1217 *pargc = argc;
1239 *pargv = (char **)argv->data; 1218 *pargv = (char **)argv->data;
1240 } 1219 }
1241
1242 #if _WIN32
1243
1244 long __cdecl __ehfilter(LPEXCEPTION_POINTERS ep)
1245 {
1246 //printf("%x\n", ep->ExceptionRecord->ExceptionCode);
1247 if (ep->ExceptionRecord->ExceptionCode == STATUS_STACK_OVERFLOW)
1248 {
1249 #ifndef DEBUG
1250 return EXCEPTION_EXECUTE_HANDLER;
1251 #endif
1252 }
1253 return EXCEPTION_CONTINUE_SEARCH;
1254 }
1255
1256 #endif