diff options
author | Josh Blum <josh@joshknows.com> | 2010-07-30 12:43:41 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-07-30 12:43:41 -0700 |
commit | 4240d5a2a1b705fe8ed5c3a1d1deef24be00d444 (patch) | |
tree | 6c292d10784049bd5f4e92e69de00f227b279cb1 /firmware/microblaze/lib/nonstdio.c | |
parent | 5dca9e6315c5f827d97351316e5bdd3a786dc4f1 (diff) | |
download | uhd-4240d5a2a1b705fe8ed5c3a1d1deef24be00d444.tar.gz uhd-4240d5a2a1b705fe8ed5c3a1d1deef24be00d444.tar.bz2 uhd-4240d5a2a1b705fe8ed5c3a1d1deef24be00d444.zip |
usrp2: reorganized firmware directory
Diffstat (limited to 'firmware/microblaze/lib/nonstdio.c')
-rw-r--r-- | firmware/microblaze/lib/nonstdio.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/firmware/microblaze/lib/nonstdio.c b/firmware/microblaze/lib/nonstdio.c index 1c991afee..4b5fa4123 100644 --- a/firmware/microblaze/lib/nonstdio.c +++ b/firmware/microblaze/lib/nonstdio.c @@ -78,3 +78,46 @@ puthex32_nl(unsigned long x) puthex32(x); newline(); } +/* +void reverse(char s[]) +{ + int c, i, j; + + for (i = 0, j = strlen(s)-1; i<j; i++, j--) { + c = s[i]; + s[i] = s[j]; + s[j] = c; + } +} + +int abs(signed long value) { + return (value >= 0) ? value : 0-value; +} + +//we'll keep the puthex functions above because they're way more lightweight. but sometimes you just want to print in decimal, you know? +char *itoa(signed long value, char *result, int base) +{ + // check that the base if valid + if (base < 2 || base > 16) { *result = 0; return result; } + + char* out = result; + signed long quotient = value; + + do { + *out = hex[ abs(quotient % base) ]; + ++out; + quotient /= base; + } while ( quotient ); + + // Only apply negative sign for base 10 + if ( value < 0 && base == 10) *out++ = '-'; + + *out = 0; + reverse( result ); + + return result; + +} +*/ + + |