Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  *  arch/alpha/lib/srm_printk.c
0004  */
0005 
0006 #include <linux/kernel.h>
0007 #include <asm/console.h>
0008 
0009 long
0010 srm_printk(const char *fmt, ...)
0011 {
0012     static char buf[1024];
0013     va_list args;
0014     long len, num_lf;
0015     char *src, *dst;
0016 
0017     va_start(args, fmt);
0018     len = vsprintf(buf, fmt, args);
0019     va_end(args);
0020 
0021     /* count number of linefeeds in string: */
0022 
0023     num_lf = 0;
0024     for (src = buf; *src; ++src) {
0025         if (*src == '\n') {
0026             ++num_lf;
0027         }
0028     }
0029 
0030     if (num_lf) {
0031         /* expand each linefeed into carriage-return/linefeed: */
0032         for (dst = src + num_lf; src >= buf; ) {
0033             if (*src == '\n') {
0034                 *dst-- = '\r';
0035             }
0036             *dst-- = *src--;
0037         }
0038     }
0039 
0040     srm_puts(buf, num_lf+len);  
0041         return len;
0042 }