Annotation of researchv9/libc/fio/fiowrite.c, revision 1.1

1.1     ! root        1: #define        FIO_IMP
        !             2: #include       "fio.h"
        !             3: #include       <libc.h>
        !             4: 
        !             5: Fwrite(fd, addr, nbytes)
        !             6:        register char *addr;
        !             7:        register long nbytes;
        !             8: {
        !             9:        register Fbuffer *f;
        !            10:        register COUNT n;
        !            11:        long nnbytes = nbytes;
        !            12: 
        !            13:        FIOSET(f, fd);
        !            14:        f->end = 0;             /* mark as writing */
        !            15:        n = &f->buf[FIOBSIZE] - f->next;
        !            16:        if(nbytes < n) n = nbytes;
        !            17:        memcpy(f->next, addr, n);
        !            18:        f->next += n;
        !            19:        nbytes -= n;
        !            20:        addr += n;
        !            21:        if(nbytes){
        !            22:                F_flush(f, fd);
        !            23:                while(nbytes >= FIOBSIZE){
        !            24:                        if(write(fd, addr, (COUNT)FIOBSIZE) != FIOBSIZE)
        !            25:                                return(-1L);
        !            26:                        addr += FIOBSIZE;
        !            27:                        nbytes -= FIOBSIZE;
        !            28:                }
        !            29:                memcpy(f->next = f->buf, addr, (COUNT)(n = nbytes));
        !            30:                f->next += n;
        !            31:        }
        !            32:        return(nnbytes);
        !            33: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.