[simu] Fix Windows builds with SD-enabled targets; Centralize SD check condition. Make some compiler checks more specific (eg. !minGW). (#4144)

This commit is contained in:
Max Paperno
2016-12-17 13:41:16 +01:00
committed by Bertrand Songis
parent 5d5dc67605
commit 143f5ce05e
2 changed files with 15 additions and 10 deletions
+13 -8
View File
@@ -24,7 +24,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <sys/stat.h> #include <sys/stat.h>
#if !defined _MSC_VER #if !defined _MSC_VER || defined __GNUC__
#include <sys/time.h> #include <sys/time.h>
#endif #endif
@@ -34,6 +34,7 @@
#if defined(SIMU_AUDIO) && defined(CPUARM) #if defined(SIMU_AUDIO) && defined(CPUARM)
#include <SDL.h> #include <SDL.h>
#undef main
#endif #endif
#if defined(TRACE_SIMPGMSPACE) #if defined(TRACE_SIMPGMSPACE)
@@ -43,6 +44,10 @@
#define TRACE_SIMPGMSPACE(...) #define TRACE_SIMPGMSPACE(...)
#endif #endif
#if defined(SDCARD) && !defined(SKIP_FATFS_DECLARATION) && !defined(SIMU_DISKIO)
#define SIMU_USE_SDCARD
#endif
uint8_t MCUCSR, MCUSR, MCUCR; uint8_t MCUCSR, MCUSR, MCUCR;
volatile uint8_t pina=0xff, pinb=0xff, pinc=0xff, pind, pine=0xff, pinf=0xff, ping=0xff, pinh=0xff, pinj=0, pinl=0; volatile uint8_t pina=0xff, pinb=0xff, pinc=0xff, pind, pine=0xff, pinf=0xff, ping=0xff, pinh=0xff, pinj=0, pinl=0;
uint8_t portb, portc, porth=0, dummyport; uint8_t portb, portc, porth=0, dummyport;
@@ -73,7 +78,7 @@ Dacc dacc;
Adc Adc0; Adc Adc0;
#endif #endif
#if defined(SDCARD) && !defined(SKIP_FATFS_DECLARATION) #if defined(SIMU_USE_SDCARD)
char simuSdDirectory[1024] = ""; char simuSdDirectory[1024] = "";
#endif #endif
@@ -308,9 +313,9 @@ void StartSimu(bool tests)
main_thread_running = (tests ? 1 : 2); // TODO rename to simu_run_mode with #define main_thread_running = (tests ? 1 : 2); // TODO rename to simu_run_mode with #define
#if defined(SDCARD) #if defined(SIMU_USE_SDCARD)
if (strlen(simuSdDirectory) == 0) { if (strlen(simuSdDirectory) == 0) {
getcwd(simuSdDirectory, 1024); f_getcwd(simuSdDirectory, 1024);
} }
#endif #endif
@@ -518,7 +523,7 @@ uint16_t stackAvailable()
return 500; return 500;
} }
#if defined(SDCARD) && !defined(SKIP_FATFS_DECLARATION) && !defined(SIMU_DISKIO) #if defined(SIMU_USE_SDCARD)
#if defined(_MSC_VER) || !defined(__GNUC__) #if defined(_MSC_VER) || !defined(__GNUC__)
#include <direct.h> #include <direct.h>
#include <stdlib.h> #include <stdlib.h>
@@ -570,7 +575,7 @@ char *findTrueFileName(const char *path)
else { else {
//find file //find file
//add to map //add to map
#if defined WIN32 || !defined __GNUC__ #if defined _MSC_VER || !defined __GNUC__
char drive[_MAX_DRIVE]; char drive[_MAX_DRIVE];
char dir[_MAX_DIR]; char dir[_MAX_DIR];
char fname[_MAX_FNAME]; char fname[_MAX_FNAME];
@@ -608,7 +613,7 @@ char *findTrueFileName(const char *path)
for (;;) { for (;;) {
struct simu::dirent * res = simu::readdir(dir); struct simu::dirent * res = simu::readdir(dir);
if (res == 0) break; if (res == 0) break;
#if defined(__APPLE__) || defined(__FreeBSD__) #if defined(WIN32) || defined(__APPLE__) || defined(__FreeBSD__)
if ((res->d_type == DT_REG) || (res->d_type == DT_LNK)) { if ((res->d_type == DT_REG) || (res->d_type == DT_LNK)) {
#else #else
if ((res->d_type == simu::DT_REG) || (res->d_type == simu::DT_LNK)) { if ((res->d_type == simu::DT_REG) || (res->d_type == simu::DT_LNK)) {
@@ -960,7 +965,7 @@ int32_t Card_state = SD_ST_MOUNTED;
uint32_t Card_CSD[4]; // TODO elsewhere uint32_t Card_CSD[4]; // TODO elsewhere
#endif #endif
#endif // #if defined(SDCARD) && !defined(SKIP_FATFS_DECLARATION) && !defined(SIMU_DISKIO) #endif // #if defined(SIMU_USE_SDCARD)
#if defined(SIMU_DISKIO) #if defined(SIMU_DISKIO)
+2 -2
View File
@@ -38,7 +38,7 @@ extern char * main_thread_error;
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#if defined(WIN32) || !defined(__GNUC__) #if defined(_MSC_VER) || !defined(__GNUC__)
#define write_backtrace(output) #define write_backtrace(output)
#else #else
#include <execinfo.h> #include <execinfo.h>
@@ -339,7 +339,7 @@ extern void rxPdcUsart( void (*pChProcess)(uint8_t x) );
#define ISR(x, ...) void x() #define ISR(x, ...) void x()
#if !defined(WIN32) && defined(__GNUC__) #if !defined(_MSC_VER) && defined(__GNUC__)
#define asm(...) #define asm(...)
#endif #endif