vsprintf.c (4d8a743cdd2690c0bc8d1b8cbd02cffb1ead849f) | vsprintf.c (0fe1ef24f7bd0020f29ffe287dfdb9ead33ca0b2) |
---|---|
1/* 2 * linux/lib/vsprintf.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ 8/* --- 8 unchanged lines hidden (view full) --- 17 */ 18 19#include <stdarg.h> 20#include <linux/module.h> 21#include <linux/types.h> 22#include <linux/string.h> 23#include <linux/ctype.h> 24#include <linux/kernel.h> | 1/* 2 * linux/lib/vsprintf.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ 8/* --- 8 unchanged lines hidden (view full) --- 17 */ 18 19#include <stdarg.h> 20#include <linux/module.h> 21#include <linux/types.h> 22#include <linux/string.h> 23#include <linux/ctype.h> 24#include <linux/kernel.h> |
25#include <linux/kallsyms.h> 26#include <linux/uaccess.h> |
|
25 26#include <asm/page.h> /* for PAGE_SIZE */ 27#include <asm/div64.h> 28 29/* Works only for digits and letters, but small and fast */ 30#define TOLOWER(x) ((x) | 0x20) 31 32/** --- 473 unchanged lines hidden (view full) --- 506 while (len < field_width--) { 507 if (buf < end) 508 *buf = ' '; 509 ++buf; 510 } 511 return buf; 512} 513 | 27 28#include <asm/page.h> /* for PAGE_SIZE */ 29#include <asm/div64.h> 30 31/* Works only for digits and letters, but small and fast */ 32#define TOLOWER(x) ((x) | 0x20) 33 34/** --- 473 unchanged lines hidden (view full) --- 508 while (len < field_width--) { 509 if (buf < end) 510 *buf = ' '; 511 ++buf; 512 } 513 return buf; 514} 515 |
516static inline void *dereference_function_descriptor(void *ptr) 517{ 518#if defined(CONFIG_IA64) || defined(CONFIG_PPC64) 519 void *p; 520 if (!probe_kernel_address(ptr, p)) 521 ptr = p; 522#endif 523 return ptr; 524} 525 526static char *symbol_string(char *buf, char *end, void *ptr, int field_width, int precision, int flags) 527{ 528 unsigned long value = (unsigned long) ptr; 529#ifdef CONFIG_KALLSYMS 530 char sym[KSYM_SYMBOL_LEN]; 531 sprint_symbol(sym, value); 532 return string(buf, end, sym, field_width, precision, flags); 533#else 534 field_width = 2*sizeof(void *); 535 flags |= SPECIAL | SMALL | ZEROPAD; 536 return number(buf, end, value, 16, field_width, precision, flags); 537#endif 538} 539 |
|
514/* 515 * Show a '%p' thing. A kernel extension is that the '%p' is followed 516 * by an extra set of alphanumeric characters that are extended format 517 * specifiers. 518 * | 540/* 541 * Show a '%p' thing. A kernel extension is that the '%p' is followed 542 * by an extra set of alphanumeric characters that are extended format 543 * specifiers. 544 * |
519 * Right now don't actually handle any such, but we will.. | 545 * Right now we just handle 'F' (for symbolic Function descriptor pointers) 546 * and 'S' (for Symbolic direct pointers), but this can easily be 547 * extended in the future (network address types etc). 548 * 549 * The difference between 'S' and 'F' is that on ia64 and ppc64 function 550 * pointers are really function descriptors, which contain a pointer the 551 * real address. |
520 */ 521static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags) 522{ | 552 */ 553static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags) 554{ |
555 switch (*fmt) { 556 case 'F': 557 ptr = dereference_function_descriptor(ptr); 558 /* Fallthrough */ 559 case 'S': 560 return symbol_string(buf, end, ptr, field_width, precision, flags); 561 } |
|
523 flags |= SMALL; 524 if (field_width == -1) { 525 field_width = 2*sizeof(void *); 526 flags |= ZEROPAD; 527 } 528 return number(buf, end, (unsigned long) ptr, 16, field_width, precision, flags); 529} 530 --- 597 unchanged lines hidden --- | 562 flags |= SMALL; 563 if (field_width == -1) { 564 field_width = 2*sizeof(void *); 565 flags |= ZEROPAD; 566 } 567 return number(buf, end, (unsigned long) ptr, 16, field_width, precision, flags); 568} 569 --- 597 unchanged lines hidden --- |