]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libbio/bgetd.c
sdiahci, sdodin: avoid calling kproc() while holding ilock()
[plan9front.git] / sys / src / libbio / bgetd.c
1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4
5 struct  bgetd
6 {
7         Biobufhdr*      b;
8         int             eof;
9 };
10
11 static int
12 Bgetdf(void *vp)
13 {
14         int c;
15         struct bgetd *bg = vp;
16
17         c = Bgetc(bg->b);
18         if(c == Beof)
19                 bg->eof = 1;
20         return c;
21 }
22
23 int
24 Bgetd(Biobufhdr *bp, double *dp)
25 {
26         double d;
27         struct bgetd b;
28
29         b.b = bp;
30         b.eof = 0;
31         d = charstod(Bgetdf, &b);
32         if(b.eof)
33                 return -1;
34         Bungetc(bp);
35         *dp = d;
36         return 1;
37 }