aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/vsprintf.c67
1 files changed, 42 insertions, 25 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 20c95121d8a1..b8a2f549ab0e 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -267,7 +267,8 @@ int strict_strtoll(const char *cp, unsigned int base, long long *res)
267} 267}
268EXPORT_SYMBOL(strict_strtoll); 268EXPORT_SYMBOL(strict_strtoll);
269 269
270static int skip_atoi(const char **s) 270static noinline_for_stack
271int skip_atoi(const char **s)
271{ 272{
272 int i = 0; 273 int i = 0;
273 274
@@ -287,7 +288,8 @@ static int skip_atoi(const char **s)
287/* Formats correctly any integer in [0,99999]. 288/* Formats correctly any integer in [0,99999].
288 * Outputs from one to five digits depending on input. 289 * Outputs from one to five digits depending on input.
289 * On i386 gcc 4.1.2 -O2: ~250 bytes of code. */ 290 * On i386 gcc 4.1.2 -O2: ~250 bytes of code. */
290static char *put_dec_trunc(char *buf, unsigned q) 291static noinline_for_stack
292char *put_dec_trunc(char *buf, unsigned q)
291{ 293{
292 unsigned d3, d2, d1, d0; 294 unsigned d3, d2, d1, d0;
293 d1 = (q>>4) & 0xf; 295 d1 = (q>>4) & 0xf;
@@ -324,7 +326,8 @@ static char *put_dec_trunc(char *buf, unsigned q)
324 return buf; 326 return buf;
325} 327}
326/* Same with if's removed. Always emits five digits */ 328/* Same with if's removed. Always emits five digits */
327static char *put_dec_full(char *buf, unsigned q) 329static noinline_for_stack
330char *put_dec_full(char *buf, unsigned q)
328{ 331{
329 /* BTW, if q is in [0,9999], 8-bit ints will be enough, */ 332 /* BTW, if q is in [0,9999], 8-bit ints will be enough, */
330 /* but anyway, gcc produces better code with full-sized ints */ 333 /* but anyway, gcc produces better code with full-sized ints */
@@ -366,7 +369,8 @@ static char *put_dec_full(char *buf, unsigned q)
366 return buf; 369 return buf;
367} 370}
368/* No inlining helps gcc to use registers better */ 371/* No inlining helps gcc to use registers better */
369static noinline char *put_dec(char *buf, unsigned long long num) 372static noinline_for_stack
373char *put_dec(char *buf, unsigned long long num)
370{ 374{
371 while (1) { 375 while (1) {
372 unsigned rem; 376 unsigned rem;
@@ -417,8 +421,9 @@ struct printf_spec {
417 s16 precision; /* # of digits/chars */ 421 s16 precision; /* # of digits/chars */
418}; 422};
419 423
420static char *number(char *buf, char *end, unsigned long long num, 424static noinline_for_stack
421 struct printf_spec spec) 425char *number(char *buf, char *end, unsigned long long num,
426 struct printf_spec spec)
422{ 427{
423 /* we are called with base 8, 10 or 16, only, thus don't need "G..." */ 428 /* we are called with base 8, 10 or 16, only, thus don't need "G..." */
424 static const char digits[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */ 429 static const char digits[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */
@@ -537,7 +542,8 @@ static char *number(char *buf, char *end, unsigned long long num,
537 return buf; 542 return buf;
538} 543}
539 544
540static char *string(char *buf, char *end, const char *s, struct printf_spec spec) 545static noinline_for_stack
546char *string(char *buf, char *end, const char *s, struct printf_spec spec)
541{ 547{
542 int len, i; 548 int len, i;
543 549
@@ -567,8 +573,9 @@ static char *string(char *buf, char *end, const char *s, struct printf_spec spec
567 return buf; 573 return buf;
568} 574}
569 575
570static char *symbol_string(char *buf, char *end, void *ptr, 576static noinline_for_stack
571 struct printf_spec spec, char ext) 577char *symbol_string(char *buf, char *end, void *ptr,
578 struct printf_spec spec, char ext)
572{ 579{
573 unsigned long value = (unsigned long) ptr; 580 unsigned long value = (unsigned long) ptr;
574#ifdef CONFIG_KALLSYMS 581#ifdef CONFIG_KALLSYMS
@@ -588,8 +595,9 @@ static char *symbol_string(char *buf, char *end, void *ptr,
588#endif 595#endif
589} 596}
590 597
591static char *resource_string(char *buf, char *end, struct resource *res, 598static noinline_for_stack
592 struct printf_spec spec, const char *fmt) 599char *resource_string(char *buf, char *end, struct resource *res,
600 struct printf_spec spec, const char *fmt)
593{ 601{
594#ifndef IO_RSRC_PRINTK_SIZE 602#ifndef IO_RSRC_PRINTK_SIZE
595#define IO_RSRC_PRINTK_SIZE 6 603#define IO_RSRC_PRINTK_SIZE 6
@@ -690,8 +698,9 @@ static char *resource_string(char *buf, char *end, struct resource *res,
690 return string(buf, end, sym, spec); 698 return string(buf, end, sym, spec);
691} 699}
692 700
693static char *mac_address_string(char *buf, char *end, u8 *addr, 701static noinline_for_stack
694 struct printf_spec spec, const char *fmt) 702char *mac_address_string(char *buf, char *end, u8 *addr,
703 struct printf_spec spec, const char *fmt)
695{ 704{
696 char mac_addr[sizeof("xx:xx:xx:xx:xx:xx")]; 705 char mac_addr[sizeof("xx:xx:xx:xx:xx:xx")];
697 char *p = mac_addr; 706 char *p = mac_addr;
@@ -714,7 +723,8 @@ static char *mac_address_string(char *buf, char *end, u8 *addr,
714 return string(buf, end, mac_addr, spec); 723 return string(buf, end, mac_addr, spec);
715} 724}
716 725
717static char *ip4_string(char *p, const u8 *addr, const char *fmt) 726static noinline_for_stack
727char *ip4_string(char *p, const u8 *addr, const char *fmt)
718{ 728{
719 int i; 729 int i;
720 bool leading_zeros = (fmt[0] == 'i'); 730 bool leading_zeros = (fmt[0] == 'i');
@@ -763,7 +773,8 @@ static char *ip4_string(char *p, const u8 *addr, const char *fmt)
763 return p; 773 return p;
764} 774}
765 775
766static char *ip6_compressed_string(char *p, const char *addr) 776static noinline_for_stack
777char *ip6_compressed_string(char *p, const char *addr)
767{ 778{
768 int i, j, range; 779 int i, j, range;
769 unsigned char zerolength[8]; 780 unsigned char zerolength[8];
@@ -843,7 +854,8 @@ static char *ip6_compressed_string(char *p, const char *addr)
843 return p; 854 return p;
844} 855}
845 856
846static char *ip6_string(char *p, const char *addr, const char *fmt) 857static noinline_for_stack
858char *ip6_string(char *p, const char *addr, const char *fmt)
847{ 859{
848 int i; 860 int i;
849 861
@@ -858,8 +870,9 @@ static char *ip6_string(char *p, const char *addr, const char *fmt)
858 return p; 870 return p;
859} 871}
860 872
861static char *ip6_addr_string(char *buf, char *end, const u8 *addr, 873static noinline_for_stack
862 struct printf_spec spec, const char *fmt) 874char *ip6_addr_string(char *buf, char *end, const u8 *addr,
875 struct printf_spec spec, const char *fmt)
863{ 876{
864 char ip6_addr[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")]; 877 char ip6_addr[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")];
865 878
@@ -871,8 +884,9 @@ static char *ip6_addr_string(char *buf, char *end, const u8 *addr,
871 return string(buf, end, ip6_addr, spec); 884 return string(buf, end, ip6_addr, spec);
872} 885}
873 886
874static char *ip4_addr_string(char *buf, char *end, const u8 *addr, 887static noinline_for_stack
875 struct printf_spec spec, const char *fmt) 888char *ip4_addr_string(char *buf, char *end, const u8 *addr,
889 struct printf_spec spec, const char *fmt)
876{ 890{
877 char ip4_addr[sizeof("255.255.255.255")]; 891 char ip4_addr[sizeof("255.255.255.255")];
878 892
@@ -881,8 +895,9 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr,
881 return string(buf, end, ip4_addr, spec); 895 return string(buf, end, ip4_addr, spec);
882} 896}
883 897
884static char *uuid_string(char *buf, char *end, const u8 *addr, 898static noinline_for_stack
885 struct printf_spec spec, const char *fmt) 899char *uuid_string(char *buf, char *end, const u8 *addr,
900 struct printf_spec spec, const char *fmt)
886{ 901{
887 char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]; 902 char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
888 char *p = uuid; 903 char *p = uuid;
@@ -970,8 +985,9 @@ static char *uuid_string(char *buf, char *end, const u8 *addr,
970 * function pointers are really function descriptors, which contain a 985 * function pointers are really function descriptors, which contain a
971 * pointer to the real address. 986 * pointer to the real address.
972 */ 987 */
973static char *pointer(const char *fmt, char *buf, char *end, void *ptr, 988static noinline_for_stack
974 struct printf_spec spec) 989char *pointer(const char *fmt, char *buf, char *end, void *ptr,
990 struct printf_spec spec)
975{ 991{
976 if (!ptr) 992 if (!ptr)
977 return string(buf, end, "(null)", spec); 993 return string(buf, end, "(null)", spec);
@@ -1040,7 +1056,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
1040 * @precision: precision of a number 1056 * @precision: precision of a number
1041 * @qualifier: qualifier of a number (long, size_t, ...) 1057 * @qualifier: qualifier of a number (long, size_t, ...)
1042 */ 1058 */
1043static int format_decode(const char *fmt, struct printf_spec *spec) 1059static noinline_for_stack
1060int format_decode(const char *fmt, struct printf_spec *spec)
1044{ 1061{
1045 const char *start = fmt; 1062 const char *start = fmt;
1046 1063