39 lines
766 B
C
39 lines
766 B
C
|
/* See LICENSE of license details. */
|
||
|
|
||
|
#include <errno.h>
|
||
|
#include <stdint.h>
|
||
|
#include <sys/types.h>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
#include "platform.h"
|
||
|
#include "stub.h"
|
||
|
#include "weak_under_alias.h"
|
||
|
#if defined(SEMIHOSTING)
|
||
|
#include "semihosting.h"
|
||
|
#endif
|
||
|
|
||
|
ssize_t __wrap_write(int fd, const void *ptr, size_t len) {
|
||
|
const uint8_t *current = (const uint8_t *)ptr;
|
||
|
#if defined(SEMIHOSTING)
|
||
|
if (isatty(fd)) {
|
||
|
for (size_t jj = 0; jj < len; jj++) {
|
||
|
sh_writec(current[jj]);
|
||
|
}
|
||
|
return len;
|
||
|
} else {
|
||
|
sh_write(current, fd);
|
||
|
return len;
|
||
|
}
|
||
|
// return len;
|
||
|
#endif
|
||
|
if (isatty(fd)) {
|
||
|
for (size_t jj = 0; jj < len; jj++) {
|
||
|
*((uint32_t *)0xFFFF0000) = current[jj];
|
||
|
}
|
||
|
return len;
|
||
|
}
|
||
|
|
||
|
return _stub(EBADF);
|
||
|
}
|
||
|
weak_under_alias(write);
|