Changeset e330da6e in mainline


Ignore:
Timestamp:
2017-03-30T06:33:22Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
907d91a
Parents:
5b46ec8
git-author:
Supragya Raj <supragyaraj@…> (2017-03-30 06:33:22)
git-committer:
Jakub Jermar <jakub@…> (2017-03-30 06:33:22)
Message:

Add support for printing ptrdiff_t

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/arm32/include/types.h

    r5b46ec8 re330da6e  
    4545typedef uint32_t pfn_t;
    4646
     47typedef int32_t ptrdiff_t;
     48
    4749typedef struct {
    4850        /** Address where the task was placed. */
  • boot/arch/ia64/include/types.h

    r5b46ec8 re330da6e  
    4040typedef uint64_t uintptr_t;
    4141
     42typedef int64_t ptrdiff_t;
     43
    4244typedef struct {
    4345        void *addr;
  • boot/arch/mips32/include/types.h

    r5b46ec8 re330da6e  
    3737typedef uint32_t uintptr_t;
    3838
     39typedef int32_t ptrdiff_t;
     40
    3941typedef struct {
    4042        /** Address where the task was placed. */
  • boot/arch/ppc32/include/types.h

    r5b46ec8 re330da6e  
    3838typedef int32_t native_t;
    3939
     40typedef int32_t ptrdiff_t;
     41
    4042typedef struct {
    4143        void *addr;
  • boot/arch/riscv64/include/types.h

    r5b46ec8 re330da6e  
    3737typedef uint64_t uintptr_t;
    3838
     39typedef int64_t ptrdiff_t;
     40
    3941typedef struct {
    4042        void *start;
  • boot/arch/sparc64/include/types.h

    r5b46ec8 re330da6e  
    3838typedef int64_t native_t;
    3939
     40typedef int64_t ptrdiff_t;
     41
    4042typedef struct {
    4143        void *addr;
  • boot/generic/src/printf_core.c

    r5b46ec8 re330da6e  
    605605                       
    606606                        switch (uc) {
    607                         /** @todo Unimplemented qualifiers:
    608                          *        t ptrdiff_t - ISO C 99
    609                          */
     607                        case 't':
     608                                /* ptrdiff_t */
     609                                if (sizeof(ptrdiff_t) == sizeof(int32_t))
     610                                        qualifier = PrintfQualifierInt;
     611                                else
     612                                        qualifier = PrintfQualifierLongLong;
    610613                        case 'h':
    611614                                /* Char or short */
  • kernel/generic/include/typedefs.h

    r5b46ec8 re330da6e  
    6161typedef volatile uint32_t ioport32_t;
    6262
     63typedef native_t ptrdiff_t;
     64
    6365#ifdef __32_BITS__
    6466
  • kernel/generic/src/printf/printf_core.c

    r5b46ec8 re330da6e  
    733733                       
    734734                        switch (uc) {
    735                         /** @todo Unimplemented qualifiers:
    736                          *        t ptrdiff_t - ISO C 99
    737                          */
     735                        case 't':
     736                                /* ptrdiff_t */
     737                                if (sizeof(ptrdiff_t) == sizeof(int32_t))
     738                                        qualifier = PrintfQualifierInt;
     739                                else
     740                                        qualifier = PrintfQualifierLongLong;
    738741                        case 'h':
    739742                                /* Char or short */
  • kernel/test/print/print2.c

    r5b46ec8 re330da6e  
    5252        TPRINTF("Real output:     [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21);
    5353       
     54        char ch[12];
     55        ptrdiff_t d, neg_d;
     56       
     57        d = &ch[0] - &ch[12];
     58        neg_d = (unsigned)(-d);
     59        TPRINTF("Testing printf(\"%%td %%tu %%tx %%ti %%to\", d, neg_d, neg_d, d, neg_d):\n");
     60        TPRINTF("Expected output: [-12] [12] [c] [-12] [14]\n");
     61        TPRINTF("Real output:     [%td] [%tu] [%tx] [%ti] [%to]\n\n", d, neg_d, neg_d, d, neg_d);
     62       
    5463        sysarg_t nat = UINTN_C(0x12345678);
    5564       
  • uspace/app/tester/print/print2.c

    r5b46ec8 re330da6e  
    5353        TPRINTF("Real output:     [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21);
    5454       
     55        char ch[12];
     56        ptrdiff_t d, neg_d;
     57       
     58        d = &ch[0] - &ch[12];
     59        neg_d = (unsigned)(-d);
     60        TPRINTF("Testing printf(\"%%td %%tu %%tx %%ti %%to\", d, neg_d, neg_d, d, neg_d):\n");
     61        TPRINTF("Expected output: [-12] [12] [c] [-12] [14]\n");
     62        TPRINTF("Real output:     [%td] [%tu] [%tx] [%ti] [%to]\n\n", d, neg_d, neg_d, d, neg_d);
     63       
    5564        return NULL;
    5665}
  • uspace/lib/c/generic/io/printf_core.c

    r5b46ec8 re330da6e  
    14481448                       
    14491449                        switch (uc) {
    1450                         /** @todo Unimplemented qualifiers:
    1451                          *        t ptrdiff_t - ISO C 99
    1452                          */
     1450                        case 't':
     1451                                /* ptrdiff_t */
     1452                                if (sizeof(ptrdiff_t) == sizeof(int32_t))
     1453                                        qualifier = PrintfQualifierInt;
     1454                                else
     1455                                        qualifier = PrintfQualifierLongLong;
    14531456                        case 'h':
    14541457                                /* Char or short */
Note: See TracChangeset for help on using the changeset viewer.