From: John Hodge Date: Sat, 30 Oct 2010 13:07:07 +0000 (+0800) Subject: Fixing vsnprintf behavior on 64-bit systems X-Git-Tag: rel0.06~4 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=a0d535a87aafc61dd4624b8a6b2d85ad7d1afd2e;p=tpg%2Facess2.git Fixing vsnprintf behavior on 64-bit systems --- diff --git a/Kernel/Makefile.BuildNum.x86_64 b/Kernel/Makefile.BuildNum.x86_64 index 16710d2d..cfc4f867 100644 --- a/Kernel/Makefile.BuildNum.x86_64 +++ b/Kernel/Makefile.BuildNum.x86_64 @@ -1 +1 @@ -BUILD_NUM = 213 +BUILD_NUM = 215 diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index c2f06854..5ba34082 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -657,7 +657,8 @@ void VT_SetTerminal(int ID) tVideo_IOCtl_Pos pos; pos.x = (gpVT_CurTerm->WritePos - gpVT_CurTerm->ViewPos) % gpVT_CurTerm->TextWidth; pos.y = (gpVT_CurTerm->WritePos - gpVT_CurTerm->ViewPos) / gpVT_CurTerm->TextWidth; - VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETCURSOR, &pos); + if( pos.x < gpVT_CurTerm->TextHeight ) + VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETCURSOR, &pos); } if( gpVT_CurTerm->Mode == TERM_MODE_TEXT ) diff --git a/Kernel/lib.c b/Kernel/lib.c index 8a07ea76..b13d2e47 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -178,6 +178,10 @@ void itoa(char *buf, Uint num, int base, int minLength, char pad) if(pos==__maxlen){return pos;}\ if(__s){__s[pos++]=ch;}else{pos++;}\ }while(0) +#define GETVAL() do {\ + if(isLongLong) val = va_arg(args, Uint64);\ + else val = va_arg(args, unsigned int);\ + }while(0) /** * \brief VArg String Number Print Formatted */ @@ -215,9 +219,6 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) goto printString; } - // Get Argument - val = va_arg(args, unsigned int); - // - Padding Side Flag if(c == '+') { bPadLeft = 1; @@ -234,8 +235,7 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) // - Minimum length if(c == '*') { // Dynamic length - minSize = val; - val = va_arg(args, unsigned int); + minSize = va_arg(args, unsigned int); c = *__format++; } else if('1' <= c && c <= '9') @@ -257,9 +257,6 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) { c = *__format++; if(c == 'l') { - #if BITS == 32 - val |= (Uint64)va_arg(args, Uint) << 32; - #endif c = *__format++; isLongLong = 1; } @@ -271,6 +268,7 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) { case 'd': case 'i': + GETVAL(); if( isLongLong && val >> 63 ) { PUTCH('-'); val = -val; @@ -282,26 +280,31 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) itoa(p, val, 10, minSize, pad); goto printString; case 'u': + GETVAL(); itoa(p, val, 10, minSize, pad); goto printString; case 'x': + GETVAL(); itoa(p, val, 16, minSize, pad); goto printString; case 'o': + GETVAL(); itoa(p, val, 8, minSize, pad); goto printString; case 'b': + GETVAL(); itoa(p, val, 2, minSize, pad); goto printString; case 'B': //Boolean + val = va_arg(args, unsigned int); if(val) p = "True"; else p = "False"; goto printString; // String - Null Terminated Array case 's': - p = (char*)(tVAddr)val; + p = va_arg(args, char*); // Get Argument printString: if(!p) p = "(null)"; len = strlen(p); @@ -311,7 +314,7 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) break; case 'C': // Non-Null Terminated Character Array - p = (char*)(tVAddr)val; + p = va_arg(args, char*); if(!p) goto printString; while(minSize--) PUTCH(*p++); break; @@ -319,6 +322,7 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) // Single Character case 'c': default: + GETVAL(); PUTCH( (Uint8)val ); break; } diff --git a/Kernel/threads.c b/Kernel/threads.c index b1a2a613..cfc06397 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -1146,7 +1146,7 @@ void Mutex_Acquire(tMutex *Mutex) Mutex->Waiting = us; Mutex->LastWaiting = us; } - #if 1 + #if 0 { int i = 0; tThread *t; diff --git a/Modules/Display/VESA/main.c b/Modules/Display/VESA/main.c index 506a8b5a..bafab9d1 100644 --- a/Modules/Display/VESA/main.c +++ b/Modules/Display/VESA/main.c @@ -519,7 +519,7 @@ void Vesa_FlipCursor(void *Arg) // Sanity 1 if(giVesaCursorX < 0 || giVesaCursorY < 0 || y*pitch + x + giVT_CharHeight*pitch > (int)gpVesaCurMode->fbSize/4) { - Debug("Cursor OOB (%i,%i)", x, y); + Log_Notice("VESA", "Cursor OOB (%i,%i)", x, y); giVesaCursorTimer = -1; return; }