I always thought that printf was non-reentrant anyway!
I don't understand what you mean by that. It seems the issue is with the reentrant version of the sbrk function, nothing related to printf.
so maybe I do actually jsut need to provide _write, _sbrk etc? event if it calls the original for now
No, you only have to provide prototypes.
Your OS does not provide <sys/xxx.h> headers, but it should. Take a look at the linux files in newlib, in your repository :
from
https://github.com/heavyweight87/Sakura ... s/unistd.h,
Code: Select all
/* Provide prototypes for most of the _<systemcall> names that are
provided in newlib for some compilers. */
int _close (int __fildes);
pid_t _fork (void);
pid_t _getpid (void);
int _link (const char *__path1, const char *__path2);
off_t _lseek (int __fildes, off_t __offset, int __whence);
_READ_WRITE_RETURN_TYPE _read (int __fd, void *__buf, size_t __nbyte);
void * _sbrk (size_t __incr);
int _unlink (const char *__path);
_READ_WRITE_RETURN_TYPE _write (int __fd, const void *__buf, size_t __nbyte);
int _execve (const char *__path, char * const __argv[], char * const __envp[]);
It provides the prototypes in the header, but the function is never defined in the code (
https://github.com/heavyweight87/Sakura ... inux/brk.c does not define a _sbrk function).
The prototypes allow newlib to make system call wrappers i think.
So you only need to provide those header files and it will work, i believe.
I agree with you that it is strange, and the comment "for some compilers" in the code is cryptic ; i don't have an explanation right now for why you need to do that, but if you do, i think it will work