]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libc/port/readn.c
libregexp: improve the transition to next available thread, instruction, and generation
[plan9front.git] / sys / src / libc / port / readn.c
1 #include <u.h>
2 #include <libc.h>
3
4 long
5 readn(int f, void *av, long n)
6 {
7         char *a;
8         long m, t;
9
10         a = av;
11         t = 0;
12         while(t < n){
13                 m = read(f, a+t, n-t);
14                 if(m <= 0){
15                         if(t == 0)
16                                 return m;
17                         break;
18                 }
19                 t += m;
20         }
21         return t;
22 }