summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1-RevB_FreedomStudio/freedom-metal/gloss/sys_write.c
blob: bfcf0cb2b9bc41bb7618f5a5038bc56f418bffcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <metal/tty.h>
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>

/* Write to a file.  */
ssize_t
_write(int file, const void *ptr, size_t len)
{
  if (file != STDOUT_FILENO) {
    errno = ENOSYS;
    return -1;
  }

  const char *bptr = ptr;
  for (size_t i = 0; i < len; ++i)
    metal_tty_putc(bptr[i]);
  return 0;
}