From: Russ Cox Date: Mon, 20 Oct 2008 22:21:59 +0000 (-0700) Subject: use Biobuf not fd for reading objects. X-Git-Tag: weekly.2009-11-06~2938 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bfc70d0f0a9103775693fd60b410464470e249d5;p=gostls13.git use Biobuf not fd for reading objects. will make reading type info easier. R=r DELTA=21 (2 added, 1 deleted, 18 changed) OCL=17491 CL=17501 --- diff --git a/src/cmd/6l/asm.c b/src/cmd/6l/asm.c index 66aecad5a9..a6f3587a66 100644 --- a/src/cmd/6l/asm.c +++ b/src/cmd/6l/asm.c @@ -900,7 +900,6 @@ putstrtab(char* name) { int linuxstrtable(void) { - char *name; int size; size = 0; diff --git a/src/cmd/6l/l.h b/src/cmd/6l/l.h index 1cc92f5032..445cc67f66 100644 --- a/src/cmd/6l/l.h +++ b/src/cmd/6l/l.h @@ -360,6 +360,7 @@ int Pconv(Fmt*); int Rconv(Fmt*); int Sconv(Fmt*); void addhist(int32, int); +void addstackmark(void); Prog* appendp(Prog*); void asmb(void); void asmdyn(void); @@ -395,7 +396,7 @@ void histtoauto(void); double ieeedtod(Ieee*); int32 ieeedtof(Ieee*); void import(void); -void ldobj(int, int32, char*); +void ldobj(Biobuf*, int32, char*); void loadlib(void); void listinit(void); Sym* lookup(char*, int); diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c index 1b57687ea7..75f7f884e2 100644 --- a/src/cmd/6l/obj.c +++ b/src/cmd/6l/obj.c @@ -454,7 +454,8 @@ void objfile(char *file) { int32 off, esym, cnt, l; - int f, work; + int work; + Biobuf *f; Sym *s; char magbuf[SARMAG]; char name[100], pname[150]; @@ -473,22 +474,22 @@ objfile(char *file) if(debug['v']) Bprint(&bso, "%5.2f ldobj: %s\n", cputime(), file); Bflush(&bso); - f = open(file, 0); - if(f < 0) { + f = Bopen(file, 0); + if(f == nil) { diag("cannot open file: %s", file); errorexit(); } - l = read(f, magbuf, SARMAG); + l = Bread(f, magbuf, SARMAG); if(l != SARMAG || strncmp(magbuf, ARMAG, SARMAG)){ /* load it as a regular file */ - l = seek(f, 0L, 2); - seek(f, 0L, 0); + l = Bseek(f, 0L, 2); + Bseek(f, 0L, 0); ldobj(f, l, file); - close(f); + Bterm(f); return; } - l = read(f, &arhdr, SAR_HDR); + l = Bread(f, &arhdr, SAR_HDR); if(l != SAR_HDR) { diag("%s: short read on archive file symbol header", file); goto out; @@ -504,12 +505,12 @@ objfile(char *file) /* * just bang the whole symbol file into memory */ - seek(f, off, 0); + Bseek(f, off, 0); cnt = esym - off; start = malloc(cnt + 10); - cnt = read(f, start, cnt); + cnt = Bread(f, start, cnt); if(cnt <= 0){ - close(f); + Bterm(f); return; } stop = &start[cnt]; @@ -533,8 +534,8 @@ objfile(char *file) l |= (e[2] & 0xff) << 8; l |= (e[3] & 0xff) << 16; l |= (e[4] & 0xff) << 24; - seek(f, l, 0); - l = read(f, &arhdr, SAR_HDR); + Bseek(f, l, 0); + l = Bread(f, &arhdr, SAR_HDR); if(l != SAR_HDR) goto bad; if(strncmp(arhdr.fmag, ARFMAG, sizeof(arhdr.fmag))) @@ -554,7 +555,7 @@ objfile(char *file) bad: diag("%s: bad or out of date archive", file); out: - close(f); + Bterm(f); } int @@ -791,7 +792,7 @@ nopout(Prog *p) } uchar* -readsome(int f, uchar *buf, uchar *good, uchar *stop, int max) +readsome(Biobuf *f, uchar *buf, uchar *good, uchar *stop, int max) { int n; @@ -801,14 +802,14 @@ readsome(int f, uchar *buf, uchar *good, uchar *stop, int max) n = MAXIO - n; if(n > max) n = max; - n = read(f, stop, n); + n = Bread(f, stop, n); if(n <= 0) return 0; return stop + n; } void -ldobj(int f, int32 c, char *pn) +ldobj(Biobuf *f, int32 c, char *pn) { vlong ipc; Prog *p, *t;