forked from Imagelibrary/rtems
2007-12-17 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/printk.c: Style.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2007-12-17 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
|
* libcsupport/src/printk.c: Style.
|
||||||
|
|
||||||
2007-12-17 Joel Sherrill <joel.sherrill@OARcorp.com>
|
2007-12-17 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||||
|
|
||||||
* score/src/threadqextractwithproxy.c: Conditionalize code that is only
|
* score/src/threadqextractwithproxy.c: Conditionalize code that is only
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* (C) Copyright 1997 -
|
* (C) Copyright 1997 -
|
||||||
* - NavIST Group - Real-Time Distributed Systems and Industrial Automation
|
* - NavIST Group - Real-Time Distributed Systems and Industrial Automation
|
||||||
*
|
*
|
||||||
@@ -11,11 +10,11 @@
|
|||||||
*
|
*
|
||||||
* This file is provided "AS IS" without warranty of any kind, either
|
* This file is provided "AS IS" without warranty of any kind, either
|
||||||
* expressed or implied.
|
* expressed or implied.
|
||||||
*--------------------------------------------------------------------------+
|
*
|
||||||
* This code is based on code by: Jose Rufino - IST
|
* This code is based on code by: Jose Rufino - IST
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*--------------------------------------------------------------------------*/
|
*/
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -25,19 +24,23 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/bspIo.h>
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------+
|
/*
|
||||||
| Function: printNum
|
* printNum - print number in a given base.
|
||||||
| Description: print number in a given base.
|
* Arguments
|
||||||
| Global Variables: None.
|
* num - number to print
|
||||||
| Arguments: num - number to print, base - base used to print the number.
|
* base - base used to print the number.
|
||||||
| Returns: Nothing.
|
*/
|
||||||
+--------------------------------------------------------------------------*/
|
static void printNum(
|
||||||
static void
|
long unsigned int num,
|
||||||
printNum(long unsigned int num, int base, int sign, int maxwidth, int lead)
|
int base,
|
||||||
|
int sign,
|
||||||
|
int maxwidth,
|
||||||
|
int lead
|
||||||
|
)
|
||||||
{
|
{
|
||||||
long unsigned int n;
|
long unsigned int n;
|
||||||
int count;
|
int count;
|
||||||
char toPrint[20];
|
char toPrint[20];
|
||||||
|
|
||||||
if ( (sign == 1) && ((long)num < 0) ) {
|
if ( (sign == 1) && ((long)num < 0) ) {
|
||||||
BSP_output_char('-');
|
BSP_output_char('-');
|
||||||
@@ -48,42 +51,43 @@ printNum(long unsigned int num, int base, int sign, int maxwidth, int lead)
|
|||||||
count = 0;
|
count = 0;
|
||||||
while ((n = num / base) > 0) {
|
while ((n = num / base) > 0) {
|
||||||
toPrint[count++] = (num - (n*base));
|
toPrint[count++] = (num - (n*base));
|
||||||
num = n ;
|
num = n;
|
||||||
}
|
}
|
||||||
toPrint[count++] = num;
|
toPrint[count++] = num;
|
||||||
|
|
||||||
for (n=maxwidth ; n > count; n-- )
|
for (n=maxwidth ; n > count; n-- )
|
||||||
BSP_output_char(lead);
|
BSP_output_char(lead);
|
||||||
|
|
||||||
for (n = 0; n < count; n++){
|
for (n = 0; n < count; n++) {
|
||||||
BSP_output_char("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]);
|
BSP_output_char("0123456789ABCDEF"[(int)(toPrint[count-(n+1)])]);
|
||||||
}
|
}
|
||||||
} /* printNum */
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------+
|
/*
|
||||||
| Function: printk
|
* vprintk
|
||||||
| Description: a simplified version of printf intended for use when the
|
*
|
||||||
console is not yet initialized or in ISR's.
|
* A simplified version of printf intended for use when the
|
||||||
| Global Variables: None.
|
* console is not yet initialized or in ISR's.
|
||||||
| Arguments: as in printf: fmt - format string, ... - unnamed arguments.
|
*
|
||||||
| Returns: Nothing.
|
* Arguments:
|
||||||
+--------------------------------------------------------------------------*/
|
* as in printf: fmt - format string, ... - unnamed arguments.
|
||||||
void
|
*/
|
||||||
vprintk(const char *fmt, va_list ap)
|
void vprintk(
|
||||||
|
const char *fmt,
|
||||||
|
va_list ap
|
||||||
|
)
|
||||||
{
|
{
|
||||||
char c, *str;
|
char c, *str;
|
||||||
int lflag, base, sign, width, lead;
|
int lflag, base, sign, width, lead;
|
||||||
|
|
||||||
for (; *fmt != '\0'; fmt++)
|
for (; *fmt != '\0'; fmt++) {
|
||||||
{
|
|
||||||
lflag = 0;
|
lflag = 0;
|
||||||
base = 0;
|
base = 0;
|
||||||
sign = 0;
|
sign = 0;
|
||||||
width = 0;
|
width = 0;
|
||||||
lead = ' ';
|
lead = ' ';
|
||||||
if (*fmt == '%')
|
if (*fmt == '%') {
|
||||||
{
|
|
||||||
fmt++;
|
fmt++;
|
||||||
if (*fmt == '0' ) {
|
if (*fmt == '0' ) {
|
||||||
lead = '0';
|
lead = '0';
|
||||||
@@ -95,13 +99,11 @@ vprintk(const char *fmt, va_list ap)
|
|||||||
fmt++;
|
fmt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((c = *fmt) == 'l')
|
if ((c = *fmt) == 'l') {
|
||||||
{
|
|
||||||
lflag = 1;
|
lflag = 1;
|
||||||
c = *++fmt;
|
c = *++fmt;
|
||||||
}
|
}
|
||||||
switch (c)
|
switch (c) {
|
||||||
{
|
|
||||||
case 'o': case 'O': base = 8; sign = 0; break;
|
case 'o': case 'O': base = 8; sign = 0; break;
|
||||||
case 'i': case 'I':
|
case 'i': case 'I':
|
||||||
case 'd': case 'D': base = 10; sign = 1; break;
|
case 'd': case 'D': base = 10; sign = 1; break;
|
||||||
@@ -123,20 +125,22 @@ vprintk(const char *fmt, va_list ap)
|
|||||||
if (base)
|
if (base)
|
||||||
printNum(lflag ? va_arg(ap, long int) : (long int)va_arg(ap, int),
|
printNum(lflag ? va_arg(ap, long int) : (long int)va_arg(ap, int),
|
||||||
base, sign, width, lead);
|
base, sign, width, lead);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
BSP_output_char(*fmt);
|
BSP_output_char(*fmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* vprintk */
|
}
|
||||||
|
|
||||||
void
|
/*
|
||||||
printk(const char *fmt, ...)
|
* printk
|
||||||
|
*
|
||||||
|
* Kernel printf function requiring minimal infrastrure.
|
||||||
|
*/
|
||||||
|
void printk(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap; /* points to each unnamed argument in turn */
|
va_list ap; /* points to each unnamed argument in turn */
|
||||||
|
|
||||||
va_start(ap, fmt); /* make ap point to 1st unnamed arg */
|
va_start(ap, fmt); /* make ap point to 1st unnamed arg */
|
||||||
vprintk(fmt, ap);
|
vprintk(fmt, ap);
|
||||||
va_end(ap); /* clean up when done */
|
va_end(ap); /* clean up when done */
|
||||||
} /* printk */
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user