Subversion Repositories HelenOS-historic

Rev

Rev 40 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 40 Rev 42
Line 47... Line 47...
47
 
47
 
48
/*
48
/*
49
 * This is a universal function for printing hexadecimal numbers of fixed
49
 * This is a universal function for printing hexadecimal numbers of fixed
50
 * width.
50
 * width.
51
 */
51
 */
52
void print_fixed_hex(__u32 num, int width)
52
void print_fixed_hex(__native num, int width)
53
{
53
{
54
    int i;
54
    int i;
55
   
55
   
56
    for (i = width*8 - 4; i >= 0; i -= 4)
56
    for (i = width*8 - 4; i >= 0; i -= 4)
57
        putchar(digits[(num>>i) & 0xf]);
57
        putchar(digits[(num>>i) & 0xf]);
Line 59... Line 59...
59
 
59
 
60
/*
60
/*
61
 * This is a universal function for printing decimal and hexadecimal numbers.
61
 * This is a universal function for printing decimal and hexadecimal numbers.
62
 * It prints only significant digits.
62
 * It prints only significant digits.
63
 */
63
 */
64
void print_number(__u32 num, int base)
64
void print_number(__native num, int base)
65
{
65
{
66
    char d[32+1];       /* this is good enough even for base == 2 */
66
    char d[sizeof(__native)*8+1];       /* this is good enough even for base == 2 */
67
        int i = 31;
67
        int i = sizeof(__native)*8-1;
68
   
68
   
69
    do {
69
    do {
70
        d[i--] = digits[num % base];
70
        d[i--] = digits[num % base];
71
    } while (num /= base);
71
    } while (num /= base);
72
   
72
   
73
    d[32] = 0; 
73
    d[sizeof(__native)*8] = 0; 
74
    print_str(&d[i + 1]);
74
    print_str(&d[i + 1]);
75
}
75
}
76
 
76
 
77
/*
77
/*
78
 * This is our function for printing formatted text.
78
 * This is our function for printing formatted text.
Line 107... Line 107...
107
                case 's':
107
                case 's':
108
                    print_str(va_arg(ap, char_ptr));
108
                    print_str(va_arg(ap, char_ptr));
109
                    goto loop;
109
                    goto loop;
110
 
110
 
111
                case 'c':
111
                case 'c':
112
                    c = va_arg(ap, char);
112
                    c = (char) va_arg(ap, int);
113
                    break;
113
                    break;
114
 
114
 
115
                /*
115
                /*
116
                         * Hexadecimal conversions with fixed width.
116
                         * Hexadecimal conversions with fixed width.
117
                         */
117
                         */