1// SPDX-License-Identifier: GPL-2.0
2/*
3 * arch/alpha/lib/srm_printk.c
4 */
5
6#include <linux/kernel.h>
7#include <asm/console.h>
8
9long
10srm_printk(const char *fmt, ...)
11{
12 static char buf[1024];
13 va_list args;
14 long len, num_lf;
15 char *src, *dst;
16
17 va_start(args, fmt);
18 len = vsprintf(buf, fmt, args);
19 va_end(args);
20
21 /* count number of linefeeds in string: */
22
23 num_lf = 0;
24 for (src = buf; *src; ++src) {
25 if (*src == '\n') {
26 ++num_lf;
27 }
28 }
29
30 if (num_lf) {
31 /* expand each linefeed into carriage-return/linefeed: */
32 for (dst = src + num_lf; src >= buf; ) {
33 if (*src == '\n') {
34 *dst-- = '\r';
35 }
36 *dst-- = *src--;
37 }
38 }
39
40 srm_puts(buf, num_lf+len);
41 return len;
42}
43

source code of linux/arch/alpha/lib/srm_printk.c