summaryrefslogtreecommitdiffstats
path: root/firmware/microblaze/lib/nonstdio.c
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-08-04 11:11:06 -0700
committerJosh Blum <josh@joshknows.com>2010-08-04 11:11:06 -0700
commitfe622fb28654e6a578395d7b688e7c1958d373be (patch)
treec4cad6eb4c77895ddbc7bf8b297f4c115e6c52f7 /firmware/microblaze/lib/nonstdio.c
parentee32fa2290f8b6abe83f1b8b33aff922f9d1e24c (diff)
parent4240d5a2a1b705fe8ed5c3a1d1deef24be00d444 (diff)
downloaduhd-fe622fb28654e6a578395d7b688e7c1958d373be.tar.gz
uhd-fe622fb28654e6a578395d7b688e7c1958d373be.tar.bz2
uhd-fe622fb28654e6a578395d7b688e7c1958d373be.zip
Merge branch 'fw_reorg'
Diffstat (limited to 'firmware/microblaze/lib/nonstdio.c')
-rw-r--r--firmware/microblaze/lib/nonstdio.c43
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;
+
+}
+*/
+
+