Changeset 26e7d6d in mainline for boot/generic/src/printf_core.c
- Timestamp:
- 2011-09-19T16:31:00Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a347a11
- Parents:
- 3842a955 (diff), 086290d (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/generic/src/printf_core.c
r3842a955 r26e7d6d 70 70 */ 71 71 #define PRINT_NUMBER_BUFFER_SIZE (64 + 5) 72 73 /** Get signed or unsigned integer argument */ 74 #define PRINTF_GET_INT_ARGUMENT(type, ap, flags) \ 75 ({ \ 76 unsigned type res; \ 77 \ 78 if ((flags) & __PRINTF_FLAG_SIGNED) { \ 79 signed type arg = va_arg((ap), signed type); \ 80 \ 81 if (arg < 0) { \ 82 res = -arg; \ 83 (flags) |= __PRINTF_FLAG_NEGATIVE; \ 84 } else \ 85 res = arg; \ 86 } else \ 87 res = va_arg((ap), unsigned type); \ 88 \ 89 res; \ 90 }) 72 91 73 92 /** Enumeration of possible arguments types. … … 171 190 } 172 191 173 return (int) (counter + 1);192 return (int) (counter); 174 193 } 175 194 … … 698 717 size_t size; 699 718 uint64_t number; 719 700 720 switch (qualifier) { 701 721 case PrintfQualifierByte: 702 722 size = sizeof(unsigned char); 703 number = (uint64_t) va_arg(ap, unsigned int);723 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 704 724 break; 705 725 case PrintfQualifierShort: 706 726 size = sizeof(unsigned short); 707 number = (uint64_t) va_arg(ap, unsigned int);727 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 708 728 break; 709 729 case PrintfQualifierInt: 710 730 size = sizeof(unsigned int); 711 number = (uint64_t) va_arg(ap, unsigned int);731 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 712 732 break; 713 733 case PrintfQualifierLong: 714 734 size = sizeof(unsigned long); 715 number = (uint64_t) va_arg(ap, unsigned long);735 number = PRINTF_GET_INT_ARGUMENT(long, ap, flags); 716 736 break; 717 737 case PrintfQualifierLongLong: 718 738 size = sizeof(unsigned long long); 719 number = (uint64_t) va_arg(ap, unsigned long long);739 number = PRINTF_GET_INT_ARGUMENT(long long, ap, flags); 720 740 break; 721 741 case PrintfQualifierPointer: … … 732 752 counter = -counter; 733 753 goto out; 734 }735 736 if (flags & __PRINTF_FLAG_SIGNED) {737 if (number & (0x1 << (size * 8 - 1))) {738 flags |= __PRINTF_FLAG_NEGATIVE;739 740 if (size == sizeof(uint64_t)) {741 number = -((int64_t) number);742 } else {743 number = ~number;744 number &=745 ~(0xFFFFFFFFFFFFFFFFll <<746 (size * 8));747 number++;748 }749 }750 754 } 751 755
Note:
See TracChangeset
for help on using the changeset viewer.