diff options
author | Josh Blum <josh@joshknows.com> | 2010-08-04 16:33:49 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-08-04 16:33:49 -0700 |
commit | 8e1d51d628afb18dc9a36f268dda1e9f48a1c2ad (patch) | |
tree | 9aea9b125848fa7fc3ea45c96bff27dde2c1e8fb /firmware/microblaze/lib/nonstdio.c | |
parent | 702d5af8ca0bab8ef295c817017df5952f6aea51 (diff) | |
parent | 70abdef8f6c6d24a99caf8d3668f32094b159903 (diff) | |
download | uhd-8e1d51d628afb18dc9a36f268dda1e9f48a1c2ad.tar.gz uhd-8e1d51d628afb18dc9a36f268dda1e9f48a1c2ad.tar.bz2 uhd-8e1d51d628afb18dc9a36f268dda1e9f48a1c2ad.zip |
Merge branch 'master' into codec_gains
Conflicts:
host/lib/CMakeLists.txt
host/lib/utils/gain_handler.cpp
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; + +} +*/ + + |