Changeset 48627ab in mainline


Ignore:
Timestamp:
2006-03-16T15:06:02Z (19 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
11eae82
Parents:
b81e7c6
Message:

New improved version of stackargs va_start and va_arg macros for mips32.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • init/init.c

    rb81e7c6 r48627ab  
    3434#include <ns.h>
    3535
    36 /*
     36
    3737static void test_printf(void)
    3838{
     
    4141        printf("We are brave enought to print numbers like %%d = '%d'\n", 0x123456);
    4242        printf("And now... '%b' byte! '%w' word! '%W' Word! \n", 0x12, 0x1234, 0x1234);
    43         printf(" '%Q' Q! Another '%q' q! \n", 0x1234567887654321ll, 0x1234567887654321ll);
    44         printf(" '%P' with 64bit value and '%p' with 32 bit value. \n", 0x1234567887654321ll, 0x12345678 );
     43        printf("'%Q' Q! Another '%q' q! \n", 0x1234567887654321ll, 0x1234567887654321ll);
     44        printf("'%Q' with 64bit value and '%p' with 32 bit value. \n", 0x1234567887654321ll, 0x12345678 );
     45        printf("'%Q' 64bit, '%p' 32bit, '%b' 8bit, '%w' 16bit, '%Q' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, 0x1234567887654321ull, "Lovely string" );
     46       
    4547        printf("Thats all, folks!\n");
    4648}
    47 */
     49
    4850
    4951extern char _heap;
     
    162164        version_print();
    163165
     166/*      test_printf(); */
    164167//      test_ping();
    165168//      test_async_ipc();
  • libc/arch/mips32/include/stackarg.h

    rb81e7c6 r48627ab  
    3535#include <types.h>
    3636
    37 typedef struct va_list {
    38         int pos;
    39         uint8_t *last;
    40 } va_list;
    41 
    42 #define va_start(ap, lst)               \
    43         (ap).pos = sizeof(lst);         \
    44         (ap).last = (uint8_t *) &(lst)
    45 
    4637/**
    4738 * va_arg macro for MIPS32 - problem is that 64 bit values must be aligned on an 8-byte boundary (32bit values not)
    4839 * To satisfy this, paddings must be sometimes inserted.
    4940 */
    50 #define va_arg(ap, type)                \
    51         (*((type *)((ap).last + ((ap).pos  += sizeof(type) + ((sizeof(type) == 8) && (((ap).pos)&4) ? 4 : 0)) - sizeof(type))))
     41
     42typedef uint8_t* va_list;
     43
     44#define va_start(ap, lst) \
     45        ((ap) = (va_list)&(lst) + sizeof(lst))
     46
     47#define va_arg(ap, type)        \
     48        (((type *)((ap) = (va_list)( (sizeof(type) <= 4) ? ((uint32_t)((ap) + 2*4 - 1) & (~3)) : ((uint32_t)((ap) + 2*8 -1) & (~7)) )))[-1])
    5249
    5350#define va_end(ap)
    5451
    55 
    56 
    5752#endif
Note: See TracChangeset for help on using the changeset viewer.