diff options
| author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2011-02-05 04:35:27 +0100 | 
|---|---|---|
| committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2011-02-05 04:35:27 +0100 | 
| commit | 61ba39a23786a7ae9694705af1d146c00a319144 (patch) | |
| tree | f9ad51bee751f7e878ac3e7ad4d45f993605c37d /libc/src/write.c | |
| parent | e2d292afdb43cd7d9391128563384e1edd53c52e (diff) | |
Getting rid of newlib, starting to implement a libc. Highly experimental, highly untested.
Diffstat (limited to 'libc/src/write.c')
| -rw-r--r-- | libc/src/write.c | 21 | 
1 files changed, 21 insertions, 0 deletions
| diff --git a/libc/src/write.c b/libc/src/write.c new file mode 100644 index 0000000..e44806c --- /dev/null +++ b/libc/src/write.c @@ -0,0 +1,21 @@ +#include "reent.h" +#include "errno.h" +#include <fio.h> + +ssize_t write(int fd, const void * buf, size_t size) { +    ssize_t r; + +    if (!fio_is_open(fd)) { +        _impure_ptr->_errno = EBADF; +        return -1; +    } +     +    r = fio_write(fd, buf, size); +     +    if (r < 0) { +        _impure_ptr->_errno = EINVAL; +        return -1; +    } +     +    return r; +} | 
