]> Cypherpunks repositories - gostls13.git/commitdiff
use Biobuf not fd for reading objects.
authorRuss Cox <rsc@golang.org>
Mon, 20 Oct 2008 22:21:59 +0000 (15:21 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 20 Oct 2008 22:21:59 +0000 (15:21 -0700)
will make reading type info easier.

R=r
DELTA=21  (2 added, 1 deleted, 18 changed)
OCL=17491
CL=17501

src/cmd/6l/asm.c
src/cmd/6l/l.h
src/cmd/6l/obj.c

index 66aecad5a98f116c98c33ccea9e955f90afa2392..a6f3587a666613a79c96f523c09b4d94bea635bd 100644 (file)
@@ -900,7 +900,6 @@ putstrtab(char* name) {
 int
 linuxstrtable(void)
 {
-       char *name;
        int size;
 
        size = 0;
index 1cc92f50320e55e5f09c81876844fc281859bdc8..445cc67f66420b918af2155e1d85822898d142c4 100644 (file)
@@ -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);
index 1b57687ea70654ab7e776067a6fc49c82329318d..75f7f884e2487c2b646b298613ca2137643be0fd 100644 (file)
@@ -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;