2008-02-06 Joel Sherrill <joel.sherrill@oarcorp.com>

* libcsupport/src/printk.c: Added width and padding for %s.
	* libmisc/cpuuse/cpuusagereport.c: Support object names that are
	strings longer than 4 chanracters.
This commit is contained in:
Joel Sherrill
2008-02-06 23:15:57 +00:00
parent 4273e70b1c
commit 6728035e8b
3 changed files with 44 additions and 8 deletions

View File

@@ -1,3 +1,9 @@
2008-02-06 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/printk.c: Added width and padding for %s.
* libmisc/cpuuse/cpuusagereport.c: Support object names that are
strings longer than 4 chanracters.
2008-02-06 Joel Sherrill <joel.sherrill@OARcorp.com> 2008-02-06 Joel Sherrill <joel.sherrill@OARcorp.com>
PR 1277/networking PR 1277/networking

View File

@@ -63,7 +63,6 @@ static void printNum(
} }
} }
/* /*
* vprintk * vprintk
* *
@@ -79,13 +78,14 @@ void vprintk(
) )
{ {
char c, *str; char c, *str;
int lflag, base, sign, width, lead; int lflag, base, sign, width, lead, minus;
for (; *fmt != '\0'; fmt++) { for (; *fmt != '\0'; fmt++) {
lflag = 0; lflag = 0;
base = 0; base = 0;
sign = 0; sign = 0;
width = 0; width = 0;
minus = 0;
lead = ' '; lead = ' ';
if (*fmt == '%') { if (*fmt == '%') {
fmt++; fmt++;
@@ -93,6 +93,10 @@ void vprintk(
lead = '0'; lead = '0';
fmt++; fmt++;
} }
if (*fmt == '-' ) {
minus = 1;
fmt++;
}
while (*fmt >= '0' && *fmt <= '9' ) { while (*fmt >= '0' && *fmt <= '9' ) {
width *= 10; width *= 10;
width += (*fmt - '0'); width += (*fmt - '0');
@@ -111,8 +115,29 @@ void vprintk(
case 'x': case 'X': base = 16; sign = 0; break; case 'x': case 'X': base = 16; sign = 0; break;
case 'p': base = 16; sign = 0; break; case 'p': base = 16; sign = 0; break;
case 's': case 's':
for (str = va_arg(ap, char *); *str; str++) { int i, len;
BSP_output_char(*str); char *s;
str = va_arg(ap, char *);
/* calculate length of string */
for ( len=0, s=str ; *s ; len++, s++ )
;
/* leading spaces */
if ( !minus )
for ( i=len ; i<width ; i++ )
BSP_output_char(' ');
/* output the string */
for ( i=0 ; i<width && *str ; str++ )
BSP_output_char(*str);
/* trailing spaces */
if ( minus )
for ( i=len ; i<width ; i++ )
BSP_output_char(' ');
}
break; break;
case 'c': case 'c':
BSP_output_char(va_arg(ap, int)); BSP_output_char(va_arg(ap, int));

View File

@@ -51,7 +51,7 @@ void rtems_cpu_usage_report_with_plugin(
uint32_t api_index; uint32_t api_index;
Thread_Control *the_thread; Thread_Control *the_thread;
Objects_Information *information; Objects_Information *information;
char name[5]; char name[13];
uint32_t ival, fval; uint32_t ival, fval;
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
struct timespec uptime, total, ran; struct timespec uptime, total, ran;
@@ -88,9 +88,9 @@ void rtems_cpu_usage_report_with_plugin(
(*print)( context, "CPU Usage by thread\n" (*print)( context, "CPU Usage by thread\n"
#if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) #if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
" ID NAME SECONDS PERCENT\n" " ID NAME SECONDS PERCENT\n"
#else #else
" ID NAME TICKS PERCENT\n" " ID NAME TICKS PERCENT\n"
#endif #endif
); );
@@ -109,7 +109,12 @@ void rtems_cpu_usage_report_with_plugin(
rtems_object_get_name( the_thread->Object.id, sizeof(name), name ); rtems_object_get_name( the_thread->Object.id, sizeof(name), name );
(*print)( context, "0x%08" PRIx32 " %4s ", the_thread->Object.id, name ); (*print)(
context,
"0x%08" PRIx32 " %-12s ",
the_thread->Object.id,
name
);
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
/* /*