X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=673811c4977a4428c8a0d9c176ff341a34c44595;hb=422701bcfbeadcc8379c3623550ffdc702311cbb;hp=8ea75c85ca1c25dd2bd69f2f9a22453698a7679d;hpb=cda9681381317b37da384bc8450795c29e8dccc8;p=xboard.git diff --git a/backend.c b/backend.c index 8ea75c8..673811c 100644 --- a/backend.c +++ b/backend.c @@ -212,10 +212,12 @@ void ParseFeatures P((char* args, ChessProgramState *cps)); void InitBackEnd3 P((void)); void FeatureDone P((ChessProgramState* cps, int val)); void InitChessProgram P((ChessProgramState *cps)); - -#ifdef WIN32 - extern void ConsoleCreate(); -#endif +double u64ToDouble P((u64 value)); + +#ifdef WIN32 + extern void ConsoleCreate(); +#endif + extern int tinyLayout, smallLayout; static ChessProgramStats programStats; @@ -258,6 +260,26 @@ static ChessProgramStats programStats; #define TN_SGA 0003 #define TN_PORT 23 +/* Some compiler can't cast u64 to double + * This function do the job for us: + + * We use the highest bit for cast, this only + * works if the highest bit is not + * in use (This should not happen) + * + * We used this for all compiler + */ +double +u64ToDouble(u64 value) +{ + double r; + u64 tmp = value & 0x7fffffffffffffff; + r = (double)(s64)tmp; + if (value & 0x8000000000000000) + r += 9.2233720368547758080e18; /* 2^63 */ + return r; +} + /* Fake up flags for now, as we aren't keeping track of castling availability yet */ int @@ -305,7 +327,7 @@ Boolean alarmSounded; /* end premove variables */ char *ics_prefix = "$"; -ics_type = ICS_GENERIC; +int ics_type = ICS_GENERIC; int currentMove = 0, forwardMostMove = 0, backwardMostMove = 0; int pauseExamForwardMostMove = 0; @@ -692,12 +714,12 @@ InitBackEnd3 P((void)) char buf[MSG_SIZ]; int err; - InitChessProgram(&first); - - #ifdef WIN32 - /* Make a console window if needed */ - if (appData.icsActive) ConsoleCreate(); - #endif + InitChessProgram(&first); + + #ifdef WIN32 + /* Make a console window if needed */ + if (appData.icsActive) ConsoleCreate(); + #endif if (appData.icsActive) { err = establish(); @@ -1466,11 +1488,11 @@ read_from_ics(isr, closure, data, count, error) int i, oldi; int buf_len; int next_out; - int tkind; -#ifdef WIN32 - /* For zippy color lines of winboard - * cleanup for gcc compiler */ - int backup; + int tkind; +#ifdef WIN32 + /* For zippy color lines of winboard + * cleanup for gcc compiler */ + int backup; #endif char *p; @@ -1728,20 +1750,20 @@ read_from_ics(isr, closure, data, count, error) oldi = i; if (appData.zippyTalk || appData.zippyPlay) { -#if ZIPPY - #ifdef WIN32 - /* Backup address for color zippy lines */ - backup = i; - if (loggedOn == TRUE) - if (ZippyControl(buf, &backup) || ZippyConverse(buf, &backup) || - (appData.zippyPlay && ZippyMatch(buf, &backup))); +#if ZIPPY + #ifdef WIN32 + /* Backup address for color zippy lines */ + backup = i; + if (loggedOn == TRUE) + if (ZippyControl(buf, &backup) || ZippyConverse(buf, &backup) || + (appData.zippyPlay && ZippyMatch(buf, &backup))); #else if (ZippyControl(buf, &i) || ZippyConverse(buf, &i) || (appData.zippyPlay && ZippyMatch(buf, &i))) { loggedOn = TRUE; continue; - } + } #endif #endif } @@ -6975,7 +6997,7 @@ MailMoveEvent() || (nCmailMovesRegistered + nCmailResults == nCmailGames)) { sprintf(string, partCommandString, appData.debugMode ? " -v" : "", appData.cmailGameName); - commandOutput = popen(string, "rb"); + commandOutput = popen(string, "r"); if (commandOutput == NULL) { DisplayError(_("Failed to invoke cmail"), 0); @@ -9251,8 +9273,8 @@ DisplayAnalysis() if (programStats.got_only_move) { strcpy(buf, programStats.movelist); } else { - nps = (((u64)programStats.nodes) / - (((double)programStats.time)/100.0)); + nps = (u64ToDouble(programStats.nodes) / + ((double)programStats.time /100.0)); cs = programStats.time % 100; s = programStats.time / 100;