Ignore:
Timestamp:
2011-03-21T22:00:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes (needs fixes).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/printf/printf_core.c

    rb50b5af2 r04803bf  
    3939#include <printf/printf_core.h>
    4040#include <print.h>
    41 #include <arch/arg.h>
     41#include <stdarg.h>
    4242#include <macros.h>
    43 #include <string.h>
     43#include <str.h>
    4444#include <arch.h>
    4545
    4646/** show prefixes 0x or 0 */
    4747#define __PRINTF_FLAG_PREFIX       0x00000001
     48
    4849/** signed / unsigned number */
    4950#define __PRINTF_FLAG_SIGNED       0x00000002
     51
    5052/** print leading zeroes */
    5153#define __PRINTF_FLAG_ZEROPADDED   0x00000004
     54
    5255/** align to left */
    5356#define __PRINTF_FLAG_LEFTALIGNED  0x00000010
     57
    5458/** always show + sign */
    5559#define __PRINTF_FLAG_SHOWPLUS     0x00000020
     60
    5661/** print space instead of plus */
    5762#define __PRINTF_FLAG_SPACESIGN    0x00000040
     63
    5864/** show big characters */
    5965#define __PRINTF_FLAG_BIGCHARS     0x00000080
     66
    6067/** number has - sign */
    6168#define __PRINTF_FLAG_NEGATIVE     0x00000100
     
    7683        PrintfQualifierLong,
    7784        PrintfQualifierLongLong,
    78         PrintfQualifierPointer
     85        PrintfQualifierPointer,
     86        PrintfQualifierSize
    7987} qualifier_t;
    8088
    81 static char nullstr[] = "(NULL)";
    82 static char digits_small[] = "0123456789abcdef";
    83 static char digits_big[] = "0123456789ABCDEF";
    84 static char invalch = U_SPECIAL;
     89static const char *nullstr = "(NULL)";
     90static const char *digits_small = "0123456789abcdef";
     91static const char *digits_big = "0123456789ABCDEF";
     92static const char invalch = U_SPECIAL;
    8593
    8694/** Print one or more characters without adding newline.
     
    254262        if (str == NULL)
    255263                return printf_putstr(nullstr, ps);
    256 
     264       
    257265        /* Print leading spaces. */
    258266        size_t strw = str_length(str);
    259267        if (precision == 0)
    260268                precision = strw;
    261 
     269       
    262270        /* Left padding */
    263271        size_t counter = 0;
     
    269277                }
    270278        }
    271 
     279       
    272280        /* Part of @a str fitting into the alloted space. */
    273281        int retval;
     
    351359    uint32_t flags, printf_spec_t *ps)
    352360{
    353         char *digits;
     361        const char *digits;
    354362        if (flags & __PRINTF_FLAG_BIGCHARS)
    355363                digits = digits_big;
     
    384392         */
    385393        if (flags & __PRINTF_FLAG_PREFIX) {
    386                 switch(base) {
     394                switch (base) {
    387395                case 2:
    388396                        /* Binary formating is not standard, but usefull */
     
    448456        /* Print prefix */
    449457        if (flags & __PRINTF_FLAG_PREFIX) {
    450                 switch(base) {
     458                switch (base) {
    451459                case 2:
    452460                        /* Binary formating is not standard, but usefull */
     
    546554 *  - ""   Signed or unsigned int (default value).@n
    547555 *  - "l"  Signed or unsigned long int.@n
    548  *         If conversion is "c", the character is wchar_t (wide character).@n
     556 *         If conversion is "c", the character is wint_t (wide character).@n
    549557 *         If conversion is "s", the string is wchar_t * (wide string).@n
    550558 *  - "ll" Signed or unsigned long long int.@n
     559 *  - "z"  Signed or unsigned ssize_t or site_t.@n
    551560 *
    552561 * CONVERSION:@n
     
    563572 *
    564573 *  - P, p Print value of a pointer. Void * value is expected and it is
    565  *         printed in hexadecimal notation with prefix (as with \%#X / \%#x
    566  *         for 32-bit or \%#X / \%#x for 64-bit long pointers).
     574 *         printed in hexadecimal notation with prefix (as with
     575 *         \%#0.8X / \%#0.8x for 32-bit or \%#0.16lX / \%#0.16lx for 64-bit
     576 *         long pointers).
    567577 *
    568578 *  - b Print value as unsigned binary number. Prefix is not printed by
     
    729739                                }
    730740                                break;
     741                        case 'z':
     742                                qualifier = PrintfQualifierSize;
     743                                i = nxt;
     744                                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
     745                                break;
    731746                        default:
    732747                                /* Default type */
     
    756771                        case 'c':
    757772                                if (qualifier == PrintfQualifierLong)
    758                                         retval = print_wchar(va_arg(ap, wchar_t), width, flags, ps);
     773                                        retval = print_wchar(va_arg(ap, wint_t), width, flags, ps);
    759774                                else
    760775                                        retval = print_char(va_arg(ap, unsigned int), width, flags, ps);
     
    777792                        case 'p':
    778793                                flags |= __PRINTF_FLAG_PREFIX;
     794                                flags |= __PRINTF_FLAG_ZEROPADDED;
    779795                                base = 16;
    780796                                qualifier = PrintfQualifierPointer;
     
    839855                        case PrintfQualifierPointer:
    840856                                size = sizeof(void *);
    841                                 number = (uint64_t) (unsigned long) va_arg(ap, void *);
     857                                precision = size << 1;
     858                                number = (uint64_t) (uintptr_t) va_arg(ap, void *);
     859                                break;
     860                        case PrintfQualifierSize:
     861                                size = sizeof(size_t);
     862                                number = (uint64_t) va_arg(ap, size_t);
    842863                                break;
    843864                        default:
Note: See TracChangeset for help on using the changeset viewer.