Changeset 925a21e in mainline for kernel/generic/src/printf/printf_core.c
- Timestamp:
- 2011-09-24T14:20:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5bf76c1
- Parents:
- 867e2555 (diff), 1ab4aca (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
-
kernel/generic/src/printf/printf_core.c
r867e2555 r925a21e 75 75 #define PRINT_NUMBER_BUFFER_SIZE (64 + 5) 76 76 77 /** Get signed or unsigned integer argument */ 78 #define PRINTF_GET_INT_ARGUMENT(type, ap, flags) \ 79 ({ \ 80 unsigned type res; \ 81 \ 82 if ((flags) & __PRINTF_FLAG_SIGNED) { \ 83 signed type arg = va_arg((ap), signed type); \ 84 \ 85 if (arg < 0) { \ 86 res = -arg; \ 87 (flags) |= __PRINTF_FLAG_NEGATIVE; \ 88 } else \ 89 res = arg; \ 90 } else \ 91 res = va_arg((ap), unsigned type); \ 92 \ 93 res; \ 94 }) 95 77 96 /** Enumeration of possible arguments types. 78 97 */ … … 207 226 } 208 227 209 return (int) (counter + 1);228 return (int) (counter); 210 229 } 211 230 … … 245 264 } 246 265 247 return (int) (counter + 1);266 return (int) (counter); 248 267 } 249 268 … … 832 851 size_t size; 833 852 uint64_t number; 853 834 854 switch (qualifier) { 835 855 case PrintfQualifierByte: 836 856 size = sizeof(unsigned char); 837 number = (uint64_t) va_arg(ap, unsigned int);857 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 838 858 break; 839 859 case PrintfQualifierShort: 840 860 size = sizeof(unsigned short); 841 number = (uint64_t) va_arg(ap, unsigned int);861 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 842 862 break; 843 863 case PrintfQualifierInt: 844 864 size = sizeof(unsigned int); 845 number = (uint64_t) va_arg(ap, unsigned int);865 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 846 866 break; 847 867 case PrintfQualifierLong: 848 868 size = sizeof(unsigned long); 849 number = (uint64_t) va_arg(ap, unsigned long);869 number = PRINTF_GET_INT_ARGUMENT(long, ap, flags); 850 870 break; 851 871 case PrintfQualifierLongLong: 852 872 size = sizeof(unsigned long long); 853 number = (uint64_t) va_arg(ap, unsigned long long);873 number = PRINTF_GET_INT_ARGUMENT(long long, ap, flags); 854 874 break; 855 875 case PrintfQualifierPointer: … … 866 886 counter = -counter; 867 887 goto out; 868 }869 870 if (flags & __PRINTF_FLAG_SIGNED) {871 if (number & (0x1 << (size * 8 - 1))) {872 flags |= __PRINTF_FLAG_NEGATIVE;873 874 if (size == sizeof(uint64_t)) {875 number = -((int64_t) number);876 } else {877 number = ~number;878 number &=879 ~(0xFFFFFFFFFFFFFFFFll <<880 (size * 8));881 number++;882 }883 }884 888 } 885 889
Note:
See TracChangeset
for help on using the changeset viewer.