Skip to content

Commit ac7dccf

Browse files
authored
Merge pull request #21912 from mguetschow/native-fputs-fwrite
cpu/native: implement fputs and fwrite
2 parents 19cccbb + bb192ee commit ac7dccf

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cpu/native/syscalls.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,28 @@ int putchar(int c)
230230
return _native_write(STDOUT_FILENO, &tmp, sizeof(tmp));
231231
}
232232

233+
int fputc(int c, FILE *fp)
234+
{
235+
char tmp = c;
236+
return _native_write(fileno(fp), &tmp, sizeof(tmp));
237+
}
238+
233239
int puts(const char *s)
234240
{
235241
int r;
236-
r = _native_write(STDOUT_FILENO, (char*)s, strlen(s));
242+
r = _native_write(STDOUT_FILENO, s, strlen(s));
237243
putchar('\n');
238244
return r;
239245
}
246+
int fputs(const char *s, FILE *fp)
247+
{
248+
return _native_write(fileno(fp), s, strlen(s));
249+
}
250+
251+
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *fp)
252+
{
253+
return _native_write(fileno(fp), ptr, size * nmemb);
254+
}
240255
#endif
241256

242257
int putc(int c, FILE *fp)

0 commit comments

Comments
 (0)