Changeset 17b1b99 in mainline
- Timestamp:
- 2006-04-17T21:09:19Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 68091bd
- Parents:
- 73e9b49
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/debug/print.c
r73e9b49 r17b1b99 36 36 #include <arch.h> 37 37 38 SPINLOCK_INITIALIZE(printflock); /**< printf spinlock */39 40 #define __PRINTF_FLAG_PREFIX 0x00000001 /* show prefixes 0x or 0 */38 SPINLOCK_INITIALIZE(printflock); /**< printf spinlock */ 39 40 #define __PRINTF_FLAG_PREFIX 0x00000001 /* show prefixes 0x or 0 */ 41 41 #define __PRINTF_FLAG_SIGNED 0x00000002 /* signed / unsigned number */ 42 42 #define __PRINTF_FLAG_ZEROPADDED 0x00000004 /* print leading zeroes */ … … 63 63 64 64 static char digits_small[] = "0123456789abcdef"; /* Small hexadecimal characters */ 65 static char digits_big[] = "0123456789ABCDEF"; /* Big hexadecimal characters */65 static char digits_big[] = "0123456789ABCDEF"; /* Big hexadecimal characters */ 66 66 67 67 static inline int isdigit(int c) … … 81 81 } 82 82 83 /** Print one string without adding \n at end 83 /** Print one string without appending '\n' to the end 84 * 84 85 * Dont use this function directly - printflock is not locked here 85 * */ 86 * 87 */ 86 88 static int putstr(const char *str) 87 89 { … … 116 118 117 119 /** Print one formatted character 120 * 118 121 * @param c character to print 119 122 * @param width … … 126 129 127 130 if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { 128 while (--width > 0) { /* one space is consumed by character itself hence predecrement */129 /* FIXME: painful slow */131 while (--width > 0) { /* one space is consumed by character itself hence the predecrement */ 132 /* FIXME: painfully slow */ 130 133 putchar(' '); 131 134 ++counter; … … 136 139 ++counter; 137 140 138 while (--width > 0) { /* one space is consumed by character itself hence predecrement */141 while (--width > 0) { /* one space is consumed by character itself hence the predecrement */ 139 142 putchar(' '); 140 143 ++counter; … … 151 154 * @return number of printed characters or EOF 152 155 */ 153 154 156 static int print_string(char *s, int width, int precision, __u64 flags) 155 157 { … … 276 278 277 279 /* print leading spaces */ 278 if (size > precision) /* We must print whole numbernot only a part */280 if (size > precision) /* We must print the whole number, not only a part */ 279 281 precision = size; 280 282 … … 347 349 /** General formatted text print 348 350 * 349 * Print string formatted according t he fmt parameter350 * and varia ntarguments. Each formatting directive351 * Print string formatted according to the fmt parameter 352 * and variadic arguments. Each formatting directive 351 353 * must have the following form: 352 354 * % [ flags ] [ width ] [ .precision ] [ type ] conversion 353 355 * 354 356 * FLAGS: 355 * # Force to print prefix. For conversion %o is prefix 0, for %x and %X are prefixes 0x and 0X and for conversion %b is prefix 0b. 357 * # Force to print prefix. 358 * For conversion %o the prefix is 0, for %x and %X prefixes are 0x and 0X and for conversion %b the prefix is 0b. 356 359 * - Align to left. 357 360 * + Print positive sign just as negative. 358 361 * (space) If printed number is positive and '+' flag is not set, print space in place of sign. 359 * 0 Print 0 as padding instead of spaces. Zeroes are placed between sign and the rest of number. This flag is ignored if '-' flag is specified. 362 * 0 Print 0 as padding instead of spaces. Zeroes are placed between sign and the rest of number. 363 * This flag is ignored if '-' flag is specified. 360 364 * 361 365 * WIDTH: … … 363 367 * If width is specified with a '*' character instead of number, width is taken from parameter list. 364 368 * Int parameter expected before parameter for processed conversion specification. 365 * If this value is negative it is taken its absolute valueand the '-' flag is set.369 * If this value is negative its absolute value is taken and the '-' flag is set. 366 370 * 367 371 * PRECISION: 368 372 * Value precision. For numbers it specifies minimum valid numbers. 369 373 * Smaller numbers are printed with leading zeroes. Bigger numbers are not affected. 370 * Strings with more than precision characters are cut ted of.371 * Just as wi dth could be '*' used insteada number.372 * A intvalue is then expected in parameters. When both width and precision are specified using '*',374 * Strings with more than precision characters are cut off. 375 * Just as with width, an '*' can be used used instead of a number. 376 * An integer value is then expected in parameters. When both width and precision are specified using '*', 373 377 * first parameter is used for width and second one for precision. 374 378 * … … 674 678 return counter; 675 679 } 676
Note:
See TracChangeset
for help on using the changeset viewer.