Changeset e16e036a in mainline for generic/src/debug/print.c
- Timestamp:
- 2005-11-07T20:04:30Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c4e8ed9d
- Parents:
- d90ca68
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/debug/print.c
rd90ca68 re16e036a 42 42 #define DEFAULT_DOUBLE_BUFFER_SIZE 128 43 43 44 void print_double(double num, __u8 modifier, __u16 precision) 44 45 /** Print NULL terminated string 46 * 47 * Print characters from str using putchar() until 48 * \\0 character is reached. 49 * 50 * @param str Characters to print. 51 * 52 */ 53 static void print_str(const char *str) 54 { 55 int i = 0; 56 char c; 57 58 while (c = str[i++]) 59 putchar(c); 60 } 61 62 63 /** Print hexadecimal digits 64 * 65 * Print fixed count of hexadecimal digits from 66 * the number num. The digits are printed in 67 * natural left-to-right order starting with 68 * the width-th digit. 69 * 70 * @param num Number containing digits. 71 * @param width Count of digits to print. 72 * 73 */ 74 static void print_fixed_hex(const __u64 num, const int width) 75 { 76 int i; 77 78 for (i = width*8 - 4; i >= 0; i -= 4) 79 putchar(digits[(num>>i) & 0xf]); 80 } 81 82 83 /** Print number in given base 84 * 85 * Print significant digits of a number in given 86 * base. 87 * 88 * @param num Number to print. 89 * @param base Base to print the number in (should 90 * be in range 2 .. 16). 91 * 92 */ 93 static void print_number(const __native num, const unsigned int base) 94 { 95 int val = num; 96 char d[sizeof(__native)*8+1]; /* this is good enough even for base == 2 */ 97 int i = sizeof(__native)*8-1; 98 99 do { 100 d[i--] = digits[val % base]; 101 } while (val /= base); 102 103 d[sizeof(__native)*8] = 0; 104 print_str(&d[i + 1]); 105 } 106 107 108 static void print_double(double num, __u8 modifier, __u16 precision) 45 109 { 46 110 double intval,intval2; … … 143 207 } 144 208 145 /** Print NULL terminated string146 *147 * Print characters from str using putchar() until148 * \\0 character is reached.149 *150 * @param str Characters to print.151 *152 */153 void print_str(const char *str)154 {155 int i = 0;156 char c;157 158 while (c = str[i++])159 putchar(c);160 }161 162 163 /** Print hexadecimal digits164 *165 * Print fixed count of hexadecimal digits from166 * the number num. The digits are printed in167 * natural left-to-right order starting with168 * the width-th digit.169 *170 * @param num Number containing digits.171 * @param width Count of digits to print.172 *173 */174 void print_fixed_hex(const __u64 num, const int width)175 {176 int i;177 178 for (i = width*8 - 4; i >= 0; i -= 4)179 putchar(digits[(num>>i) & 0xf]);180 }181 182 183 /** Print number in given base184 *185 * Print significant digits of a number in given186 * base.187 *188 * @param num Number to print.189 * @param base Base to print the number in (should190 * be in range 2 .. 16).191 *192 */193 void print_number(const __native num, const unsigned int base)194 {195 int val = num;196 char d[sizeof(__native)*8+1]; /* this is good enough even for base == 2 */197 int i = sizeof(__native)*8-1;198 199 do {200 d[i--] = digits[val % base];201 } while (val /= base);202 203 d[sizeof(__native)*8] = 0;204 print_str(&d[i + 1]);205 }206 207 209 208 210 /** General formatted text print
Note:
See TracChangeset
for help on using the changeset viewer.