You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
582 B

  1. /*
  2. * support for stdio output to a trace port
  3. * Karl Palsson, 2014 <karlp@remake.is>
  4. */
  5. #include <errno.h>
  6. #include <stdio.h>
  7. #include <unistd.h>
  8. #include "trace.h"
  9. #ifndef STIMULUS_STDIO
  10. #define STIMULUS_STDIO 0
  11. #endif
  12. int _write(int file, char *ptr, int len);
  13. int _write(int file, char *ptr, int len)
  14. {
  15. int i;
  16. if (file == STDOUT_FILENO || file == STDERR_FILENO) {
  17. for (i = 0; i < len; i++) {
  18. if (ptr[i] == '\n') {
  19. trace_send_blocking8(STIMULUS_STDIO, '\r');
  20. }
  21. trace_send_blocking8(STIMULUS_STDIO, ptr[i]);
  22. }
  23. return i;
  24. }
  25. errno = EIO;
  26. return -1;
  27. }