From: John Hodge Date: Sun, 20 Jun 2010 09:53:38 +0000 (+0800) Subject: Misc debug to fix a printf bug, traced the bug to 64-bit division code X-Git-Tag: rel0.06~136 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=789ec8473604750d130abed9c31dac26a9b5dd2a;p=tpg%2Facess2.git Misc debug to fix a printf bug, traced the bug to 64-bit division code --- diff --git a/Usermode/Applications/ifconfig_src/main.c b/Usermode/Applications/ifconfig_src/main.c index ba788383..2fe0f24f 100644 --- a/Usermode/Applications/ifconfig_src/main.c +++ b/Usermode/Applications/ifconfig_src/main.c @@ -39,8 +39,11 @@ int main(int argc, char *argv[]) if( strcmp(argv[1], "autoconf") == 0 ) { DoAutoConfig(argv[2]); + return 0; } + PrintUsage(argv[0]); + return 0; } @@ -125,6 +128,7 @@ int AddInterface( char *Device ) dp = open(IPSTACK_ROOT, OPENFLAG_READ); ret = ioctl(dp, 4, Device); + printf("AddInterface: ret = 0x%x = %i\n", ret, ret); close(dp); if( ret < 0 ) { diff --git a/Usermode/Libraries/libc.so_src/fileIO.c b/Usermode/Libraries/libc.so_src/fileIO.c index 1b1d3f38..7149b3eb 100644 --- a/Usermode/Libraries/libc.so_src/fileIO.c +++ b/Usermode/Libraries/libc.so_src/fileIO.c @@ -286,12 +286,12 @@ EXPORT int vsprintf(char * __s, const char *__format, va_list __args) //sprintfv /** - \fn EXPORT void vsnprintf(char *buf, const char *format, va_list args) - \brief Prints a formatted string to a buffer - \param buf Pointer - Destination Buffer - \param format String - Format String - \param args VarArgs List - Arguments -*/ + * \fn EXPORT void vsnprintf(char *buf, const char *format, va_list args) + * \brief Prints a formatted string to a buffer + * \param buf Pointer - Destination Buffer + * \param format String - Format String + * \param args VarArgs List - Arguments + */ EXPORT int vsnprintf(char *buf, size_t __maxlen, const char *format, va_list args) { char tmp[65]; @@ -441,6 +441,12 @@ const char cUCDIGITS[] = "0123456789ABCDEF"; /** * \fn static void itoa(char *buf, uint64_t num, int base, int minLength, char pad, int bSigned) * \brief Convert an integer into a character string + * \param buf Destination Buffer + * \param num Number to convert + * \param base Base-n number output + * \param minLength Minimum length of output + * \param pad Padding used to ensure minLength + * \param bSigned Signed number output? */ EXPORT void itoa(char *buf, uint64_t num, size_t base, int minLength, char pad, int bSigned) { @@ -460,6 +466,7 @@ EXPORT void itoa(char *buf, uint64_t num, size_t base, int minLength, char pad, } else bSigned = 0; + // Encode into reversed string while(num > base-1) { tmpBuf[pos++] = cUCDIGITS[ num % base ]; num = (uint64_t) num / (uint64_t)base; // Shift {number} right 1 digit diff --git a/Usermode/Libraries/libgcc.so_src/libgcc.c b/Usermode/Libraries/libgcc.so_src/libgcc.c index 6e7fb089..794c2091 100644 --- a/Usermode/Libraries/libgcc.so_src/libgcc.c +++ b/Usermode/Libraries/libgcc.so_src/libgcc.c @@ -106,6 +106,7 @@ uint64_t __umoddi3(uint64_t Num, uint64_t Den) // Speedups for common operations if(Den == 1) return 0; if(Den == 2) return Num & 0x01; + if(Den == 8) return Num & 0x07; if(Den == 16) return Num & 0x0F; return Num - __udivdi3(Num, Den) * Den; #endif