srm_printk.c 656 B

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