]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: write only to standard error
authorRuss Cox <rsc@golang.org>
Tue, 14 Dec 2010 16:52:42 +0000 (11:52 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 14 Dec 2010 16:52:42 +0000 (11:52 -0500)
Will mail a warning to golang-nuts once this is submitted.

R=r, niemeyer
CC=golang-dev
https://golang.org/cl/3573043

src/pkg/runtime/print.c
src/pkg/runtime/proc.c
src/pkg/runtime/runtime.c
src/pkg/runtime/runtime.h

index 922c49e03699f279e2d5f3cd891a272ed14673cc..3b4bb103d07dd12f83653511f28ee7303e2a034c 100644 (file)
@@ -29,7 +29,7 @@ runtime·dump(byte *p, int32 n)
 void
 runtime·prints(int8 *s)
 {
-       runtime·write(runtime·fd, s, runtime·findnull((byte*)s));
+       runtime·write(2, s, runtime·findnull((byte*)s));
 }
 
 #pragma textflag 7
@@ -65,7 +65,7 @@ vprintf(int8 *s, byte *arg)
                if(*p != '%')
                        continue;
                if(p > lp)
-                       runtime·write(runtime·fd, lp, p-lp);
+                       runtime·write(2, lp, p-lp);
                p++;
                narg = nil;
                switch(*p) {
@@ -155,7 +155,7 @@ vprintf(int8 *s, byte *arg)
                lp = p+1;
        }
        if(p > lp)
-               runtime·write(runtime·fd, lp, p-lp);
+               runtime·write(2, lp, p-lp);
 
 //     unlock(&debuglock);
 }
@@ -181,10 +181,10 @@ void
 runtime·printbool(bool v)
 {
        if(v) {
-               runtime·write(runtime·fd, (byte*)"true", 4);
+               runtime·write(2, (byte*)"true", 4);
                return;
        }
-       runtime·write(runtime·fd, (byte*)"false", 5);
+       runtime·write(2, (byte*)"false", 5);
 }
 
 void
@@ -195,15 +195,15 @@ runtime·printfloat(float64 v)
        float64 h;
 
        if(runtime·isNaN(v)) {
-               runtime·write(runtime·fd, "NaN", 3);
+               runtime·write(2, "NaN", 3);
                return;
        }
        if(runtime·isInf(v, 1)) {
-               runtime·write(runtime·fd, "+Inf", 4);
+               runtime·write(2, "+Inf", 4);
                return;
        }
        if(runtime·isInf(v, -1)) {
-               runtime·write(runtime·fd, "-Inf", 4);
+               runtime·write(2, "-Inf", 4);
                return;
        }
 
@@ -262,16 +262,16 @@ runtime·printfloat(float64 v)
        buf[n+4] = (e/100) + '0';
        buf[n+5] = (e/10)%10 + '0';
        buf[n+6] = (e%10) + '0';
-       runtime·write(runtime·fd, buf, n+7);
+       runtime·write(2, buf, n+7);
 }
 
 void
 runtime·printcomplex(Complex128 v)
 {
-       runtime·write(runtime·fd, "(", 1);
+       runtime·write(2, "(", 1);
        runtime·printfloat(v.real);
        runtime·printfloat(v.imag);
-       runtime·write(runtime·fd, "i)", 2);
+       runtime·write(2, "i)", 2);
 }
 
 void
@@ -286,14 +286,14 @@ runtime·printuint(uint64 v)
                        break;
                v = v/10;
        }
-       runtime·write(runtime·fd, buf+i, nelem(buf)-i);
+       runtime·write(2, buf+i, nelem(buf)-i);
 }
 
 void
 runtime·printint(int64 v)
 {
        if(v < 0) {
-               runtime·write(runtime·fd, "-", 1);
+               runtime·write(2, "-", 1);
                v = -v;
        }
        runtime·printuint(v);
@@ -313,7 +313,7 @@ runtime·printhex(uint64 v)
                buf[--i] = '0';
        buf[--i] = 'x';
        buf[--i] = '0';
-       runtime·write(runtime·fd, buf+i, nelem(buf)-i);
+       runtime·write(2, buf+i, nelem(buf)-i);
 }
 
 void
@@ -328,23 +328,23 @@ runtime·printstring(String v)
        extern int32 runtime·maxstring;
 
        if(v.len > runtime·maxstring) {
-               runtime·write(runtime·fd, "[invalid string]", 16);
+               runtime·write(2, "[invalid string]", 16);
                return;
        }
        if(v.len > 0)
-               runtime·write(runtime·fd, v.str, v.len);
+               runtime·write(2, v.str, v.len);
 }
 
 void
 runtime·printsp(void)
 {
-       runtime·write(runtime·fd, " ", 1);
+       runtime·write(2, " ", 1);
 }
 
 void
 runtime·printnl(void)
 {
-       runtime·write(runtime·fd, "\n", 1);
+       runtime·write(2, "\n", 1);
 }
 
 void
index 3d5ee24c492341a7c120e018f6e2a4ded53235a9..d30d5985ece9145700adba887181fa0007b3ee4d 100644 (file)
@@ -1028,7 +1028,6 @@ runtime·panic(Eface e)
        }
 
        // ran out of deferred calls - old-school panic now
-       runtime·fd = 2;
        printpanics(g->panic);
        runtime·dopanic(0);
 }
index a2e31d806f3d1f4bafc01519219f16524ea7d534..ad5e97f497203248792744d7b893bf2d44259107 100644 (file)
@@ -9,7 +9,6 @@ enum {
 };
 
 int32  runtime·panicking      = 0;
-int32  runtime·fd             = 1;
 
 int32
 runtime·gotraceback(void)
@@ -25,7 +24,6 @@ runtime·gotraceback(void)
 void
 runtime·dopanic(int32 unused)
 {
-       runtime·fd = 2;
        if(runtime·panicking) {
                runtime·printf("double panic\n");
                runtime·exit(3);
@@ -70,7 +68,6 @@ runtime·throwinit(void)
 void
 runtime·throw(int8 *s)
 {
-       runtime·fd = 2;
        runtime·printf("throw: %s\n", s);
        runtime·dopanic(0);
        *(int32*)0 = 0; // not reached
index 37c8103f341c41c767533a98e8ac2f8daa6557f4..a0b03545e6a1dee97db8aa52575e30ee05eccaa5 100644 (file)
@@ -361,7 +361,6 @@ M*  runtime·allm;
 int32  runtime·goidgen;
 extern int32   runtime·gomaxprocs;
 extern int32   runtime·panicking;
-extern int32   runtime·fd;    // usually 1; set to 2 when panicking
 extern int32   runtime·gcwaiting;             // gc is waiting to run
 int8*  runtime·goos;
 extern bool    runtime·iscgo;