summaryrefslogtreecommitdiff
path: root/src/cmd/dist
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/dist')
-rw-r--r--src/cmd/dist/a.h4
-rw-r--r--src/cmd/dist/arm.c3
-rw-r--r--src/cmd/dist/buf.c2
-rw-r--r--src/cmd/dist/build.c267
-rw-r--r--src/cmd/dist/buildgc.c38
-rw-r--r--src/cmd/dist/buildruntime.c84
-rw-r--r--src/cmd/dist/goc2c.c833
-rw-r--r--src/cmd/dist/plan9.c6
-rw-r--r--src/cmd/dist/unix.c16
-rw-r--r--src/cmd/dist/windows.c6
10 files changed, 253 insertions, 1006 deletions
diff --git a/src/cmd/dist/a.h b/src/cmd/dist/a.h
index 6222e5060..288063b94 100644
--- a/src/cmd/dist/a.h
+++ b/src/cmd/dist/a.h
@@ -108,9 +108,6 @@ void mkzexperiment(char*, char*);
// buildgo.c
void mkzdefaultcc(char*, char*);
-// goc2c.c
-void goc2c(char*, char*);
-
// main.c
extern int vflag;
extern int sflag;
@@ -129,6 +126,7 @@ bool isfile(char *p);
char* lastelem(char*);
Time mtime(char*);
void readfile(Buf*, char*);
+void copyfile(char*, char*, int);
void run(Buf *b, char *dir, int mode, char *cmd, ...);
void runv(Buf *b, char *dir, int mode, Vec *argv);
void bgrunv(char *dir, int mode, Vec *argv);
diff --git a/src/cmd/dist/arm.c b/src/cmd/dist/arm.c
index 52a621c5d..1ce7b7710 100644
--- a/src/cmd/dist/arm.c
+++ b/src/cmd/dist/arm.c
@@ -21,7 +21,8 @@ xgetgoarm(void)
// FreeBSD has broken VFP support
return "5";
#endif
- if(xtryexecfunc(useVFPv3))
+ // NaCl always has VFP support.
+ if(streq(goos, "nacl") || xtryexecfunc(useVFPv3))
return "7";
else if(xtryexecfunc(useVFPv1))
return "6";
diff --git a/src/cmd/dist/buf.c b/src/cmd/dist/buf.c
index 45fb1954d..2ddc6be75 100644
--- a/src/cmd/dist/buf.c
+++ b/src/cmd/dist/buf.c
@@ -202,7 +202,7 @@ vadd(Vec *v, char *p)
}
// vaddn adds a string consisting of the n bytes at p to the vector.
-void
+static void
vaddn(Vec *v, char *p, int n)
{
char *q;
diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c
index 6884e0aae..d638ae4eb 100644
--- a/src/cmd/dist/build.c
+++ b/src/cmd/dist/build.c
@@ -35,7 +35,6 @@ bool rebuildall;
bool defaultclang;
static bool shouldbuild(char*, char*);
-static void copy(char*, char*, int);
static void dopack(char*, char*, char**, int);
static char *findgoversion(void);
@@ -56,6 +55,7 @@ static char *okgoos[] = {
"darwin",
"dragonfly",
"linux",
+ "android",
"solaris",
"freebsd",
"nacl",
@@ -366,8 +366,8 @@ static char *oldtool[] = {
// not be in release branches.
static char *unreleased[] = {
"src/cmd/link",
- "src/pkg/debug/goobj",
- "src/pkg/old",
+ "src/debug/goobj",
+ "src/old",
};
// setup sets up the tree for the initial build.
@@ -590,7 +590,7 @@ static struct {
"$GOROOT/pkg/obj/$GOHOSTOS_$GOHOSTARCH/libbio.a",
"$GOROOT/pkg/obj/$GOHOSTOS_$GOHOSTARCH/lib9.a",
}},
- {"pkg/runtime", {
+ {"runtime", {
"zaexperiment.h", // must sort above zasm
"zasm_$GOOS_$GOARCH.h",
"zsys_$GOOS_$GOARCH.s",
@@ -607,7 +607,6 @@ char *depsuffix[] = {
".h",
".s",
".go",
- ".goc",
};
// gentab records how to generate some trivial files.
@@ -639,7 +638,7 @@ install(char *dir)
{
char *name, *p, *elem, *prefix, *exe;
bool islib, ispkg, isgo, stale, ispackcmd;
- Buf b, b1, path;
+ Buf b, b1, path, final_path, final_name;
Vec compile, files, link, go, missing, clean, lib, extra;
Time ttarg, t;
int i, j, k, n, doclean, targ;
@@ -654,6 +653,8 @@ install(char *dir)
binit(&b);
binit(&b1);
binit(&path);
+ binit(&final_path);
+ binit(&final_name);
vinit(&compile);
vinit(&files);
vinit(&link);
@@ -666,15 +667,9 @@ install(char *dir)
// path = full path to dir.
bpathf(&path, "%s/src/%s", goroot, dir);
+ bpathf(&final_path, "%s/src/%s", goroot_final, dir);
name = lastelem(dir);
- // For misc/prof, copy into the tool directory and we're done.
- if(hasprefix(dir, "misc/")) {
- copy(bpathf(&b, "%s/%s", tooldir, name),
- bpathf(&b1, "%s/misc/%s", goroot, name), 1);
- goto out;
- }
-
// set up gcc command line on first run.
if(gccargs.len == 0) {
bprintf(&b, "%s %s", defaultcc, defaultcflags);
@@ -704,7 +699,7 @@ install(char *dir)
}
islib = hasprefix(dir, "lib") || streq(dir, "cmd/cc") || streq(dir, "cmd/gc");
- ispkg = hasprefix(dir, "pkg");
+ ispkg = !islib && !hasprefix(dir, "cmd/");
isgo = ispkg || streq(dir, "cmd/go") || streq(dir, "cmd/cgo");
exe = "";
@@ -730,11 +725,11 @@ install(char *dir)
// Go library (package).
ispackcmd = 1;
vadd(&link, "pack"); // program name - unused here, but all the other cases record one
- p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir+4);
+ p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir);
*xstrrchr(p, '/') = '\0';
xmkdirall(p);
targ = link.len;
- vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, goos, goarch, dir+4));
+ vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, goos, goarch, dir));
} else if(streq(dir, "cmd/go") || streq(dir, "cmd/cgo")) {
// Go command.
vadd(&link, bpathf(&b, "%s/%sl", tooldir, gochar));
@@ -881,18 +876,22 @@ install(char *dir)
goto out;
// For package runtime, copy some files into the work space.
- if(streq(dir, "pkg/runtime")) {
- copy(bpathf(&b, "%s/arch_GOARCH.h", workdir),
+ if(streq(dir, "runtime")) {
+ copyfile(bpathf(&b, "%s/arch_GOARCH.h", workdir),
bpathf(&b1, "%s/arch_%s.h", bstr(&path), goarch), 0);
- copy(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir),
+ copyfile(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir),
bpathf(&b1, "%s/defs_%s_%s.h", bstr(&path), goos, goarch), 0);
p = bpathf(&b1, "%s/signal_%s_%s.h", bstr(&path), goos, goarch);
if(isfile(p))
- copy(bpathf(&b, "%s/signal_GOOS_GOARCH.h", workdir), p, 0);
- copy(bpathf(&b, "%s/os_GOOS.h", workdir),
+ copyfile(bpathf(&b, "%s/signal_GOOS_GOARCH.h", workdir), p, 0);
+ copyfile(bpathf(&b, "%s/os_GOOS.h", workdir),
bpathf(&b1, "%s/os_%s.h", bstr(&path), goos), 0);
- copy(bpathf(&b, "%s/signals_GOOS.h", workdir),
+ copyfile(bpathf(&b, "%s/signals_GOOS.h", workdir),
bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos), 0);
+ copyfile(bpathf(&b, "%s/pkg/%s_%s/textflag.h", goroot, goos, goarch),
+ bpathf(&b1, "%s/src/cmd/ld/textflag.h", goroot), 0);
+ copyfile(bpathf(&b, "%s/pkg/%s_%s/funcdata.h", goroot, goos, goarch),
+ bpathf(&b1, "%s/src/runtime/funcdata.h", goroot), 0);
}
// Generate any missing files; regenerate existing ones.
@@ -907,7 +906,7 @@ install(char *dir)
errprintf("generate %s\n", p);
gentab[j].gen(bstr(&path), p);
// Do not add generated file to clean list.
- // In pkg/runtime, we want to be able to
+ // In runtime, we want to be able to
// build the package with the go tool,
// and it assumes these generated files already
// exist (it does not know how to build them).
@@ -925,27 +924,11 @@ install(char *dir)
// One more copy for package runtime.
// The last batch was required for the generators.
// This one is generated.
- if(streq(dir, "pkg/runtime")) {
- copy(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir),
+ if(streq(dir, "runtime")) {
+ copyfile(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir),
bpathf(&b1, "%s/zasm_%s_%s.h", bstr(&path), goos, goarch), 0);
}
- // Generate .c files from .goc files.
- if(streq(dir, "pkg/runtime")) {
- for(i=0; i<files.len; i++) {
- p = files.p[i];
- if(!hassuffix(p, ".goc"))
- continue;
- // b = path/zp but with _goos_goarch.c instead of .goc
- bprintf(&b, "%s%sz%s", bstr(&path), slash, lastelem(p));
- b.len -= 4;
- bwritef(&b, "_%s_%s.c", goos, goarch);
- goc2c(p, bstr(&b));
- vadd(&files, bstr(&b));
- }
- vuniq(&files);
- }
-
if((!streq(goos, gohostos) || !streq(goarch, gohostarch)) && isgo) {
// We've generated the right files; the go command can do the build.
if(vflag > 1)
@@ -1086,7 +1069,7 @@ install(char *dir)
else
vadd(&compile, "main");
- if(streq(dir, "pkg/runtime"))
+ if(streq(dir, "runtime"))
vadd(&compile, "-+");
vcopy(&compile, go.p, go.len);
@@ -1115,11 +1098,11 @@ install(char *dir)
nobuild:
// In package runtime, we install runtime.h and cgocall.h too,
// for use by cgo compilation.
- if(streq(dir, "pkg/runtime")) {
- copy(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch),
- bpathf(&b1, "%s/src/pkg/runtime/cgocall.h", goroot), 0);
- copy(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch),
- bpathf(&b1, "%s/src/pkg/runtime/runtime.h", goroot), 0);
+ if(streq(dir, "runtime")) {
+ copyfile(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch),
+ bpathf(&b1, "%s/src/runtime/cgocall.h", goroot), 0);
+ copyfile(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch),
+ bpathf(&b1, "%s/src/runtime/runtime.h", goroot), 0);
}
@@ -1149,7 +1132,7 @@ matchfield(char *f)
p = xstrrchr(f, ',');
if(p == nil)
- return streq(f, goos) || streq(f, goarch) || streq(f, "cmd_go_bootstrap") || streq(f, "go1.1");
+ return streq(f, goos) || streq(f, goarch) || streq(f, "cmd_go_bootstrap") || streq(f, "go1.1") || (streq(goos, "android") && streq(f, "linux"));
*p = 0;
res = matchfield(f) && matchfield(p+1);
*p = ',';
@@ -1241,8 +1224,8 @@ out:
}
// copy copies the file src to dst, via memory (so only good for small files).
-static void
-copy(char *dst, char *src, int exec)
+void
+copyfile(char *dst, char *src, int exec)
{
Buf b;
@@ -1303,8 +1286,6 @@ static char *buildorder[] = {
"libbio",
"liblink",
- "misc/pprof",
-
"cmd/cc", // must be before c
"cmd/gc", // must be before g
"cmd/%sl", // must be before a, c, g
@@ -1316,47 +1297,47 @@ static char *buildorder[] = {
// back when there were build scripts. Will have to
// be maintained by hand, but shouldn't change very
// often.
- "pkg/runtime",
- "pkg/errors",
- "pkg/sync/atomic",
- "pkg/sync",
- "pkg/io",
- "pkg/unicode",
- "pkg/unicode/utf8",
- "pkg/unicode/utf16",
- "pkg/bytes",
- "pkg/math",
- "pkg/strings",
- "pkg/strconv",
- "pkg/bufio",
- "pkg/sort",
- "pkg/container/heap",
- "pkg/encoding/base64",
- "pkg/syscall",
- "pkg/time",
- "pkg/os",
- "pkg/reflect",
- "pkg/fmt",
- "pkg/encoding",
- "pkg/encoding/json",
- "pkg/flag",
- "pkg/path/filepath",
- "pkg/path",
- "pkg/io/ioutil",
- "pkg/log",
- "pkg/regexp/syntax",
- "pkg/regexp",
- "pkg/go/token",
- "pkg/go/scanner",
- "pkg/go/ast",
- "pkg/go/parser",
- "pkg/os/exec",
- "pkg/os/signal",
- "pkg/net/url",
- "pkg/text/template/parse",
- "pkg/text/template",
- "pkg/go/doc",
- "pkg/go/build",
+ "runtime",
+ "errors",
+ "sync/atomic",
+ "sync",
+ "io",
+ "unicode",
+ "unicode/utf8",
+ "unicode/utf16",
+ "bytes",
+ "math",
+ "strings",
+ "strconv",
+ "bufio",
+ "sort",
+ "container/heap",
+ "encoding/base64",
+ "syscall",
+ "time",
+ "os",
+ "reflect",
+ "fmt",
+ "encoding",
+ "encoding/json",
+ "flag",
+ "path/filepath",
+ "path",
+ "io/ioutil",
+ "log",
+ "regexp/syntax",
+ "regexp",
+ "go/token",
+ "go/scanner",
+ "go/ast",
+ "go/parser",
+ "os/exec",
+ "os/signal",
+ "net/url",
+ "text/template/parse",
+ "text/template",
+ "go/doc",
+ "go/build",
"cmd/go",
};
@@ -1364,6 +1345,7 @@ static char *buildorder[] = {
// It is bigger than the buildorder because we clean all the
// compilers but build only the $GOARCH ones.
static char *cleantab[] = {
+ // Commands and C libraries.
"cmd/5a",
"cmd/5c",
"cmd/5g",
@@ -1382,46 +1364,48 @@ static char *cleantab[] = {
"lib9",
"libbio",
"liblink",
- "pkg/bufio",
- "pkg/bytes",
- "pkg/container/heap",
- "pkg/encoding",
- "pkg/encoding/base64",
- "pkg/encoding/json",
- "pkg/errors",
- "pkg/flag",
- "pkg/fmt",
- "pkg/go/ast",
- "pkg/go/build",
- "pkg/go/doc",
- "pkg/go/parser",
- "pkg/go/scanner",
- "pkg/go/token",
- "pkg/io",
- "pkg/io/ioutil",
- "pkg/log",
- "pkg/math",
- "pkg/net/url",
- "pkg/os",
- "pkg/os/exec",
- "pkg/path",
- "pkg/path/filepath",
- "pkg/reflect",
- "pkg/regexp",
- "pkg/regexp/syntax",
- "pkg/runtime",
- "pkg/sort",
- "pkg/strconv",
- "pkg/strings",
- "pkg/sync",
- "pkg/sync/atomic",
- "pkg/syscall",
- "pkg/text/template",
- "pkg/text/template/parse",
- "pkg/time",
- "pkg/unicode",
- "pkg/unicode/utf16",
- "pkg/unicode/utf8",
+
+ // Go packages.
+ "bufio",
+ "bytes",
+ "container/heap",
+ "encoding",
+ "encoding/base64",
+ "encoding/json",
+ "errors",
+ "flag",
+ "fmt",
+ "go/ast",
+ "go/build",
+ "go/doc",
+ "go/parser",
+ "go/scanner",
+ "go/token",
+ "io",
+ "io/ioutil",
+ "log",
+ "math",
+ "net/url",
+ "os",
+ "os/exec",
+ "path",
+ "path/filepath",
+ "reflect",
+ "regexp",
+ "regexp/syntax",
+ "runtime",
+ "sort",
+ "strconv",
+ "strings",
+ "sync",
+ "sync/atomic",
+ "syscall",
+ "text/template",
+ "text/template/parse",
+ "time",
+ "unicode",
+ "unicode/utf16",
+ "unicode/utf8",
};
static void
@@ -1450,9 +1434,9 @@ clean(void)
xremove(bpathf(&b, "%s/%s", bstr(&path), cleantab[i]+4));
}
- // remove src/pkg/runtime/z* unconditionally
+ // remove src/runtime/z* unconditionally
vreset(&dir);
- bpathf(&path, "%s/src/pkg/runtime", goroot);
+ bpathf(&path, "%s/src/runtime", goroot);
xreaddir(&dir, bstr(&path));
for(j=0; j<dir.len; j++) {
if(hasprefix(dir.p[j], "z"))
@@ -1589,6 +1573,15 @@ cmdbootstrap(int argc, char **argv)
if(argc > 0)
usage();
+ if(isdir(bpathf(&b, "%s/src/pkg", goroot))) {
+ fatal("\n\n"
+ "The Go package sources have moved to $GOROOT/src.\n"
+ "*** %s still exists. ***\n"
+ "It probably contains stale files that may confuse the build.\n"
+ "Please (check what's there and) remove it and try again.\n"
+ "See http://golang.org/s/go14nopkg\n", bpathf(&b, "%s/src/pkg", goroot));
+ }
+
if(rebuildall)
clean();
goversion = findgoversion();
@@ -1619,9 +1612,9 @@ cmdbootstrap(int argc, char **argv)
xsetenv("GOARCH", goarch);
xsetenv("GOOS", goos);
- // Build pkg/runtime for actual goos/goarch too.
+ // Build runtime for actual goos/goarch too.
if(!streq(goos, gohostos) || !streq(goarch, gohostarch))
- install("pkg/runtime");
+ install("runtime");
bfree(&b);
}
diff --git a/src/cmd/dist/buildgc.c b/src/cmd/dist/buildgc.c
index 1f0625daa..66adf6857 100644
--- a/src/cmd/dist/buildgc.c
+++ b/src/cmd/dist/buildgc.c
@@ -65,24 +65,35 @@ gcopnames(char *dir, char *file)
// mkanames reads [568].out.h and writes anames[568].c
// The format is much the same as the Go opcodes above.
+// it also writes out cnames array for C_* constants.
void
mkanames(char *dir, char *file)
{
- int i, ch;
- Buf in, b, out;
+ int i, j, ch;
+ Buf in, b, out, out2;
Vec lines;
char *p;
binit(&b);
binit(&in);
binit(&out);
+ binit(&out2);
vinit(&lines);
ch = file[xstrlen(file)-3];
bprintf(&b, "%s/../cmd/%cl/%c.out.h", dir, ch, ch);
readfile(&in, bstr(&b));
splitlines(&lines, bstr(&in));
- bprintf(&out, "char* anames%c[] = {\n", ch);
+
+ // Include link.h so that the extern declaration there is
+ // checked against the non-extern declaration we are generating.
+ bwritestr(&out, bprintf(&b, "#include <u.h>\n"));
+ bwritestr(&out, bprintf(&b, "#include <libc.h>\n"));
+ bwritestr(&out, bprintf(&b, "#include <bio.h>\n"));
+ bwritestr(&out, bprintf(&b, "#include <link.h>\n"));
+ bwritestr(&out, bprintf(&b, "\n"));
+
+ bwritestr(&out, bprintf(&b, "char* anames%c[] = {\n", ch));
for(i=0; i<lines.len; i++) {
if(hasprefix(lines.p[i], "\tA")) {
p = xstrstr(lines.p[i], ",");
@@ -96,10 +107,31 @@ mkanames(char *dir, char *file)
}
}
bwritestr(&out, "};\n");
+
+ j=0;
+ bprintf(&out2, "char* cnames%c[] = {\n", ch);
+ for(i=0; i<lines.len; i++) {
+ if(hasprefix(lines.p[i], "\tC_")) {
+ p = xstrstr(lines.p[i], ",");
+ if(p)
+ *p = '\0';
+ p = xstrstr(lines.p[i], "\n");
+ if(p)
+ *p = '\0';
+ p = lines.p[i] + 3;
+ bwritestr(&out2, bprintf(&b, "\t\"%s\",\n", p));
+ j++;
+ }
+ }
+ bwritestr(&out2, "};\n");
+ if(j>0)
+ bwriteb(&out, &out2);
+
writefile(&out, file, 0);
bfree(&b);
bfree(&in);
bfree(&out);
+ bfree(&out2);
vfree(&lines);
}
diff --git a/src/cmd/dist/buildruntime.c b/src/cmd/dist/buildruntime.c
index ba5993b2f..bb774e05f 100644
--- a/src/cmd/dist/buildruntime.c
+++ b/src/cmd/dist/buildruntime.c
@@ -5,7 +5,7 @@
#include "a.h"
/*
- * Helpers for building pkg/runtime.
+ * Helpers for building runtime.
*/
// mkzversion writes zversion.go:
@@ -30,7 +30,8 @@ mkzversion(char *dir, char *file)
"package runtime\n"
"\n"
"const defaultGoroot = `%s`\n"
- "const theVersion = `%s`\n", goroot_final, goversion));
+ "const theVersion = `%s`\n"
+ "var buildVersion = theVersion\n", goroot_final, goversion));
writefile(&out, file, 0);
@@ -108,10 +109,14 @@ mkzgoos(char *dir, char *file)
binit(&b);
binit(&out);
+
+ bwritestr(&out, "// auto generated by go tool dist\n\n");
+
+ if(streq(goos, "linux")) {
+ bwritestr(&out, "// +build !android\n\n");
+ }
bwritestr(&out, bprintf(&b,
- "// auto generated by go tool dist\n"
- "\n"
"package runtime\n"
"\n"
"const theGoos = `%s`\n", goos));
@@ -130,17 +135,14 @@ static struct {
{"386", "",
"#define get_tls(r) MOVL TLS, r\n"
"#define g(r) 0(r)(TLS*1)\n"
- "#define m(r) 4(r)(TLS*1)\n"
},
{"amd64p32", "",
"#define get_tls(r) MOVL TLS, r\n"
"#define g(r) 0(r)(TLS*1)\n"
- "#define m(r) 4(r)(TLS*1)\n"
},
{"amd64", "",
"#define get_tls(r) MOVQ TLS, r\n"
"#define g(r) 0(r)(TLS*1)\n"
- "#define m(r) 8(r)(TLS*1)\n"
},
{"arm", "",
@@ -160,11 +162,12 @@ mkzasm(char *dir, char *file)
{
int i, n;
char *aggr, *p;
- Buf in, b, out, exp;
+ Buf in, b, b1, out, exp;
Vec argv, lines, fields;
binit(&in);
binit(&b);
+ binit(&b1);
binit(&out);
binit(&exp);
vinit(&argv);
@@ -172,6 +175,10 @@ mkzasm(char *dir, char *file)
vinit(&fields);
bwritestr(&out, "// auto generated by go tool dist\n\n");
+ if(streq(goos, "linux")) {
+ bwritestr(&out, "// +build !android\n\n");
+ }
+
for(i=0; i<nelem(zasmhdr); i++) {
if(hasprefix(goarch, zasmhdr[i].goarch) && hasprefix(goos, zasmhdr[i].goos)) {
bwritestr(&out, zasmhdr[i].hdr);
@@ -181,6 +188,9 @@ mkzasm(char *dir, char *file)
fatal("unknown $GOOS/$GOARCH in mkzasm");
ok:
+ copyfile(bpathf(&b, "%s/pkg/%s_%s/textflag.h", goroot, goos, goarch),
+ bpathf(&b1, "%s/src/cmd/ld/textflag.h", goroot), 0);
+
// Run 6c -D GOOS_goos -D GOARCH_goarch -I workdir -a -n -o workdir/proc.acid proc.c
// to get acid [sic] output. Run once without the -a -o workdir/proc.acid in order to
// report compilation failures (the -o redirects all messages, unfortunately).
@@ -192,6 +202,8 @@ ok:
vadd(&argv, bprintf(&b, "GOARCH_%s", goarch));
vadd(&argv, "-I");
vadd(&argv, bprintf(&b, "%s", workdir));
+ vadd(&argv, "-I");
+ vadd(&argv, bprintf(&b, "%s/pkg/%s_%s", goroot, goos, goarch));
vadd(&argv, "-n");
vadd(&argv, "-a");
vadd(&argv, "-o");
@@ -230,6 +242,12 @@ ok:
aggr = "cbctxt";
else if(streq(fields.p[1], "SEH"))
aggr = "seh";
+ else if(streq(fields.p[1], "Alg"))
+ aggr = "alg";
+ else if(streq(fields.p[1], "Panic"))
+ aggr = "panic";
+ else if(streq(fields.p[1], "Stack"))
+ aggr = "stack";
}
if(hasprefix(lines.p[i], "}"))
aggr = nil;
@@ -262,6 +280,7 @@ ok:
bfree(&in);
bfree(&b);
+ bfree(&b1);
bfree(&out);
bfree(&exp);
vfree(&argv);
@@ -283,6 +302,10 @@ mkzsys(char *dir, char *file)
binit(&out);
bwritestr(&out, "// auto generated by go tool dist\n\n");
+ if(streq(goos, "linux")) {
+ bwritestr(&out, "// +build !android\n\n");
+ }
+
if(streq(goos, "windows")) {
bwritef(&out,
"// runtime·callbackasm is called by external code to\n"
@@ -306,16 +329,20 @@ mkzsys(char *dir, char *file)
static char *runtimedefs[] = {
"defs.c",
+ "malloc.c",
+ "mcache.c",
+ "mgc0.c",
"proc.c",
"parfor.c",
+ "stack.c",
};
// mkzruntimedefs writes zruntime_defs_$GOOS_$GOARCH.h,
// which contains Go struct definitions equivalent to the C ones.
// Mostly we just write the output of 6c -q to the file.
// However, we run it on multiple files, so we have to delete
-// the duplicated definitions, and we don't care about the funcs
-// and consts, so we delete those too.
+// the duplicated definitions, and we don't care about the funcs,
+// so we delete those too.
//
void
mkzruntimedefs(char *dir, char *file)
@@ -335,13 +362,24 @@ mkzruntimedefs(char *dir, char *file)
vinit(&seen);
bwritestr(&out, "// auto generated by go tool dist\n"
- "\n"
+ "\n");
+
+ if(streq(goos, "linux")) {
+ bwritestr(&out, "// +build !android\n\n");
+ }
+
+ bwritestr(&out,
"package runtime\n"
"import \"unsafe\"\n"
"var _ unsafe.Pointer\n"
"\n"
);
+ // Do not emit definitions for these.
+ vadd(&seen, "true");
+ vadd(&seen, "false");
+ vadd(&seen, "raceenabled");
+ vadd(&seen, "allgs");
// Run 6c -D GOOS_goos -D GOARCH_goarch -I workdir -q -n -o workdir/runtimedefs
// on each of the runtimedefs C files.
@@ -352,6 +390,8 @@ mkzruntimedefs(char *dir, char *file)
vadd(&argv, bprintf(&b, "GOARCH_%s", goarch));
vadd(&argv, "-I");
vadd(&argv, bprintf(&b, "%s", workdir));
+ vadd(&argv, "-I");
+ vadd(&argv, bprintf(&b, "%s/pkg/%s_%s", goroot, goos, goarch));
vadd(&argv, "-q");
vadd(&argv, "-n");
vadd(&argv, "-o");
@@ -371,15 +411,15 @@ mkzruntimedefs(char *dir, char *file)
splitlines(&lines, bstr(&in));
for(i=0; i<lines.len; i++) {
p = lines.p[i];
- // Drop comment, func, and const lines.
- if(hasprefix(p, "//") || hasprefix(p, "const") || hasprefix(p, "func"))
+ // Drop comment and func lines.
+ if(hasprefix(p, "//") || hasprefix(p, "func"))
continue;
// Note beginning of type or var decl, which can be multiline.
// Remove duplicates. The linear check of seen here makes the
// whole processing quadratic in aggregate, but there are only
// about 100 declarations, so this is okay (and simple).
- if(hasprefix(p, "type ") || hasprefix(p, "var ")) {
+ if(hasprefix(p, "type ") || hasprefix(p, "var ") || hasprefix(p, "const ")) {
splitfields(&fields, p);
if(fields.len < 2)
continue;
@@ -390,6 +430,17 @@ mkzruntimedefs(char *dir, char *file)
}
vadd(&seen, fields.p[1]);
}
+
+ // Const lines are printed in original case (usually upper). Add a leading _ as needed.
+ if(hasprefix(p, "const ")) {
+ if('A' <= p[6] && p[6] <= 'Z')
+ bwritestr(&out, "const _");
+ else
+ bwritestr(&out, "const ");
+ bwritestr(&out, p+6);
+ continue;
+ }
+
if(skip) {
if(hasprefix(p, "}"))
skip = 0;
@@ -398,6 +449,11 @@ mkzruntimedefs(char *dir, char *file)
bwritestr(&out, p);
}
+
+ // Some windows specific const.
+ if(streq(goos, "windows")) {
+ bwritestr(&out, bprintf(&b, "const cb_max = %d\n", MAXWINCB));
+ }
writefile(&out, file, 0);
diff --git a/src/cmd/dist/goc2c.c b/src/cmd/dist/goc2c.c
deleted file mode 100644
index 38627657e..000000000
--- a/src/cmd/dist/goc2c.c
+++ /dev/null
@@ -1,833 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "a.h"
-
-/*
- * Translate a .goc file into a .c file. A .goc file is a combination
- * of a limited form of Go with C.
- */
-
-/*
- package PACKAGENAME
- {# line}
- func NAME([NAME TYPE { , NAME TYPE }]) [(NAME TYPE { , NAME TYPE })] \{
- C code with proper brace nesting
- \}
-*/
-
-/*
- * We generate C code which implements the function such that it can
- * be called from Go and executes the C code.
- */
-
-static char *input;
-static Buf *output;
-#define EOF -1
-
-enum
-{
- use64bitint = 1,
-};
-
-static int
-xgetchar(void)
-{
- int c;
-
- c = *input;
- if(c == 0)
- return EOF;
- input++;
- return c;
-}
-
-static void
-xungetc(void)
-{
- input--;
-}
-
-static void
-xputchar(char c)
-{
- bwrite(output, &c, 1);
-}
-
-static int
-xisspace(int c)
-{
- return c == ' ' || c == '\t' || c == '\r' || c == '\n';
-}
-
-/* Whether we're emitting for gcc */
-static int gcc;
-
-/* File and line number */
-static const char *file;
-static unsigned int lineno;
-
-/* List of names and types. */
-struct params {
- struct params *next;
- char *name;
- char *type;
-};
-
-/* index into type_table */
-enum {
- Bool,
- Float,
- Int,
- Uint,
- Uintptr,
- String,
- Slice,
- Eface,
- Complex128,
- Float32,
- Float64,
-};
-
-static struct {
- char *name;
- int size;
- int rnd; // alignment
-} type_table[] = {
- /*
- * variable sized first, for easy replacement.
- * order matches enum above.
- * default is 32-bit architecture sizes.
- * spelling as in package runtime, so intgo/uintgo not int/uint.
- */
- {"bool", 1},
- {"float", 4},
- {"intgo", 4},
- {"uintgo", 4},
- {"uintptr", 4},
- {"String", 8},
- {"Slice", 12},
- {"Eface", 8},
- {"Complex128", 16},
-
- /* fixed size */
- {"float32", 4},
- {"float64", 8},
- {"byte", 1},
- {"int8", 1},
- {"uint8", 1},
- {"int16", 2},
- {"uint16", 2},
- {"int32", 4},
- {"rune", 4},
- {"uint32", 4},
- {"int64", 8},
- {"uint64", 8},
-
- {nil, 0},
-};
-
-/* Fixed structure alignment (non-gcc only) */
-int structround = 4;
-
-/* Unexpected EOF. */
-static void
-bad_eof(void)
-{
- fatal("%s:%d: unexpected EOF\n", file, lineno);
-}
-
-/* Free a list of parameters. */
-static void
-free_params(struct params *p)
-{
- while (p != nil) {
- struct params *next;
-
- next = p->next;
- xfree(p->name);
- xfree(p->type);
- xfree(p);
- p = next;
- }
-}
-
-/* Read a character, tracking lineno. */
-static int
-getchar_update_lineno(void)
-{
- int c;
-
- c = xgetchar();
- if (c == '\n')
- ++lineno;
- return c;
-}
-
-/* Read a character, giving an error on EOF, tracking lineno. */
-static int
-getchar_no_eof(void)
-{
- int c;
-
- c = getchar_update_lineno();
- if (c == EOF)
- bad_eof();
- return c;
-}
-
-/* Read a character, skipping comments. */
-static int
-getchar_skipping_comments(void)
-{
- int c;
-
- while (1) {
- c = getchar_update_lineno();
- if (c != '/')
- return c;
-
- c = xgetchar();
- if (c == '/') {
- do {
- c = getchar_update_lineno();
- } while (c != EOF && c != '\n');
- return c;
- } else if (c == '*') {
- while (1) {
- c = getchar_update_lineno();
- if (c == EOF)
- return EOF;
- if (c == '*') {
- do {
- c = getchar_update_lineno();
- } while (c == '*');
- if (c == '/')
- break;
- }
- }
- } else {
- xungetc();
- return '/';
- }
- }
-}
-
-/*
- * Read and return a token. Tokens are string or character literals
- * or else delimited by whitespace or by [(),{}].
- * The latter are all returned as single characters.
- */
-static char *
-read_token(void)
-{
- int c, q;
- char *buf;
- unsigned int alc, off;
- char* delims = "(),{}";
-
- while (1) {
- c = getchar_skipping_comments();
- if (c == EOF)
- return nil;
- if (!xisspace(c))
- break;
- }
- alc = 16;
- buf = xmalloc(alc + 1);
- off = 0;
- if(c == '"' || c == '\'') {
- q = c;
- buf[off] = c;
- ++off;
- while (1) {
- if (off+2 >= alc) { // room for c and maybe next char
- alc *= 2;
- buf = xrealloc(buf, alc + 1);
- }
- c = getchar_no_eof();
- buf[off] = c;
- ++off;
- if(c == q)
- break;
- if(c == '\\') {
- buf[off] = getchar_no_eof();
- ++off;
- }
- }
- } else if (xstrrchr(delims, c) != nil) {
- buf[off] = c;
- ++off;
- } else {
- while (1) {
- if (off >= alc) {
- alc *= 2;
- buf = xrealloc(buf, alc + 1);
- }
- buf[off] = c;
- ++off;
- c = getchar_skipping_comments();
- if (c == EOF)
- break;
- if (xisspace(c) || xstrrchr(delims, c) != nil) {
- if (c == '\n')
- lineno--;
- xungetc();
- break;
- }
- }
- }
- buf[off] = '\0';
- return buf;
-}
-
-/* Read a token, giving an error on EOF. */
-static char *
-read_token_no_eof(void)
-{
- char *token = read_token();
- if (token == nil)
- bad_eof();
- return token;
-}
-
-/* Read the package clause, and return the package name. */
-static char *
-read_package(void)
-{
- char *token;
-
- token = read_token_no_eof();
- if (token == nil)
- fatal("%s:%d: no token\n", file, lineno);
- if (!streq(token, "package")) {
- fatal("%s:%d: expected \"package\", got \"%s\"\n",
- file, lineno, token);
- }
- return read_token_no_eof();
-}
-
-/* Read and copy preprocessor lines. */
-static void
-read_preprocessor_lines(void)
-{
- int first;
-
- first = 1;
- while (1) {
- int c;
-
- do {
- c = getchar_skipping_comments();
- } while (xisspace(c));
- if (c != '#') {
- xungetc();
- break;
- }
- if(first) {
- first = 0;
- xputchar('\n');
- }
- xputchar(c);
- do {
- c = getchar_update_lineno();
- xputchar(c);
- } while (c != '\n');
- }
-}
-
-/*
- * Read a type in Go syntax and return a type in C syntax. We only
- * permit basic types and pointers.
- */
-static char *
-read_type(void)
-{
- char *p, *op, *q;
- int pointer_count;
- unsigned int len;
-
- p = read_token_no_eof();
- if (*p != '*' && !streq(p, "int") && !streq(p, "uint"))
- return p;
- op = p;
- pointer_count = 0;
- while (*p == '*') {
- ++pointer_count;
- ++p;
- }
- len = xstrlen(p);
- q = xmalloc(len + 2 + pointer_count + 1);
- xmemmove(q, p, len);
-
- // Turn int/uint into intgo/uintgo.
- if((len == 3 && xmemcmp(q, "int", 3) == 0) || (len == 4 && xmemcmp(q, "uint", 4) == 0)) {
- q[len++] = 'g';
- q[len++] = 'o';
- }
-
- while (pointer_count-- > 0)
- q[len++] = '*';
-
- q[len] = '\0';
- xfree(op);
- return q;
-}
-
-/* Return the size of the given type. */
-static int
-type_size(char *p, int *rnd)
-{
- int i;
-
- if(p[xstrlen(p)-1] == '*') {
- *rnd = type_table[Uintptr].rnd;
- return type_table[Uintptr].size;
- }
-
- if(streq(p, "Iface"))
- p = "Eface";
-
- for(i=0; type_table[i].name; i++)
- if(streq(type_table[i].name, p)) {
- *rnd = type_table[i].rnd;
- return type_table[i].size;
- }
- fatal("%s:%d: unknown type %s\n", file, lineno, p);
- return 0;
-}
-
-/*
- * Read a list of parameters. Each parameter is a name and a type.
- * The list ends with a ')'. We have already read the '('.
- */
-static struct params *
-read_params(int *poffset)
-{
- char *token;
- struct params *ret, **pp, *p;
- int offset, size, rnd;
-
- ret = nil;
- pp = &ret;
- token = read_token_no_eof();
- offset = 0;
- if (!streq(token, ")")) {
- while (1) {
- p = xmalloc(sizeof(struct params));
- p->name = token;
- p->next = nil;
- *pp = p;
- pp = &p->next;
-
- if(streq(token, "...")) {
- p->type = xstrdup("");
- } else {
- p->type = read_type();
- rnd = 0;
- size = type_size(p->type, &rnd);
- if(rnd > structround)
- rnd = structround;
- if(offset%rnd)
- offset += rnd - offset%rnd;
- offset += size;
- }
-
- token = read_token_no_eof();
- if (!streq(token, ","))
- break;
- token = read_token_no_eof();
- }
- }
- if (!streq(token, ")")) {
- fatal("%s:%d: expected '('\n",
- file, lineno);
- }
- if (poffset != nil)
- *poffset = offset;
- return ret;
-}
-
-/*
- * Read a function header. This reads up to and including the initial
- * '{' character. Returns 1 if it read a header, 0 at EOF.
- */
-static int
-read_func_header(char **name, struct params **params, int *paramwid, struct params **rets)
-{
- int lastline;
- char *token;
-
- lastline = -1;
- while (1) {
- read_preprocessor_lines();
- token = read_token();
- if (token == nil)
- return 0;
- if (streq(token, "func")) {
- if(lastline != -1)
- bwritef(output, "\n");
- break;
- }
- if (lastline != lineno) {
- if (lastline == lineno-1)
- bwritef(output, "\n");
- else
- bwritef(output, "\n#line %d \"%s\"\n", lineno, file);
- lastline = lineno;
- }
- bwritef(output, "%s ", token);
- }
-
- *name = read_token_no_eof();
-
- token = read_token();
- if (token == nil || !streq(token, "(")) {
- fatal("%s:%d: expected \"(\"\n",
- file, lineno);
- }
- *params = read_params(paramwid);
-
- token = read_token();
- if (token == nil || !streq(token, "("))
- *rets = nil;
- else {
- *rets = read_params(nil);
- token = read_token();
- }
- if (token == nil || !streq(token, "{")) {
- fatal("%s:%d: expected \"{\"\n",
- file, lineno);
- }
- return 1;
-}
-
-/* Write out parameters. */
-static void
-write_params(struct params *params, int *first)
-{
- struct params *p;
-
- for (p = params; p != nil; p = p->next) {
- if (*first)
- *first = 0;
- else
- bwritef(output, ", ");
- bwritef(output, "%s %s", p->type, p->name);
- }
-}
-
-/* Write a 6g function header. */
-static void
-write_6g_func_header(char *package, char *name, struct params *params,
- int paramwid, struct params *rets)
-{
- int first, n;
- struct params *p;
-
- bwritef(output, "void\n");
- if(!contains(name, "·"))
- bwritef(output, "%s·", package);
- bwritef(output, "%s(", name);
-
- first = 1;
- write_params(params, &first);
-
- /* insert padding to align output struct */
- if(rets != nil && paramwid%structround != 0) {
- n = structround - paramwid%structround;
- if(n & 1)
- bwritef(output, ", uint8");
- if(n & 2)
- bwritef(output, ", uint16");
- if(n & 4)
- bwritef(output, ", uint32");
- }
-
- write_params(rets, &first);
- bwritef(output, ")\n{\n");
-
- for (p = rets; p != nil; p = p->next) {
- if(streq(p->name, "..."))
- continue;
- if(streq(p->type, "Slice"))
- bwritef(output, "\t%s.array = 0;\n\t%s.len = 0;\n\t%s.cap = 0;\n", p->name, p->name, p->name);
- else if(streq(p->type, "String"))
- bwritef(output, "\t%s.str = 0;\n\t%s.len = 0;\n", p->name, p->name);
- else if(streq(p->type, "Eface"))
- bwritef(output, "\t%s.type = 0;\n\t%s.data = 0;\n", p->name, p->name);
- else if(streq(p->type, "Iface"))
- bwritef(output, "\t%s.tab = 0;\n\t%s.data = 0;\n", p->name, p->name);
- else if(streq(p->type, "Complex128"))
- bwritef(output, "\t%s.real = 0;\n\t%s.imag = 0;\n", p->name, p->name);
- else
- bwritef(output, "\t%s = 0;\n", p->name);
- bwritef(output, "\tFLUSH(&%s);\n", p->name);
- }
-}
-
-/* Write a 6g function trailer. */
-static void
-write_6g_func_trailer(struct params *rets)
-{
- struct params *p;
-
- for (p = rets; p != nil; p = p->next)
- if(!streq(p->name, "..."))
- bwritef(output, "\tFLUSH(&%s);\n", p->name);
- bwritef(output, "}\n");
-}
-
-/* Define the gcc function return type if necessary. */
-static void
-define_gcc_return_type(char *package, char *name, struct params *rets)
-{
- struct params *p;
-
- if (rets == nil || rets->next == nil)
- return;
- bwritef(output, "struct %s_%s_ret {\n", package, name);
- for (p = rets; p != nil; p = p->next)
- bwritef(output, " %s %s;\n", p->type, p->name);
- bwritef(output, "};\n");
-}
-
-/* Write out the gcc function return type. */
-static void
-write_gcc_return_type(char *package, char *name, struct params *rets)
-{
- if (rets == nil)
- bwritef(output, "void");
- else if (rets->next == nil)
- bwritef(output, "%s", rets->type);
- else
- bwritef(output, "struct %s_%s_ret", package, name);
-}
-
-/* Write out a gcc function header. */
-static void
-write_gcc_func_header(char *package, char *name, struct params *params,
- struct params *rets)
-{
- int first;
- struct params *p;
-
- define_gcc_return_type(package, name, rets);
- write_gcc_return_type(package, name, rets);
- bwritef(output, " %s_%s(", package, name);
- first = 1;
- write_params(params, &first);
- bwritef(output, ") asm (\"%s.%s\");\n", package, name);
- write_gcc_return_type(package, name, rets);
- bwritef(output, " %s_%s(", package, name);
- first = 1;
- write_params(params, &first);
- bwritef(output, ")\n{\n");
- for (p = rets; p != nil; p = p->next)
- bwritef(output, " %s %s;\n", p->type, p->name);
-}
-
-/* Write out a gcc function trailer. */
-static void
-write_gcc_func_trailer(char *package, char *name, struct params *rets)
-{
- if (rets == nil) {
- // nothing to do
- }
- else if (rets->next == nil)
- bwritef(output, "return %s;\n", rets->name);
- else {
- struct params *p;
-
- bwritef(output, " {\n struct %s_%s_ret __ret;\n", package, name);
- for (p = rets; p != nil; p = p->next)
- bwritef(output, " __ret.%s = %s;\n", p->name, p->name);
- bwritef(output, " return __ret;\n }\n");
- }
- bwritef(output, "}\n");
-}
-
-/* Write out a function header. */
-static void
-write_func_header(char *package, char *name,
- struct params *params, int paramwid,
- struct params *rets)
-{
- if (gcc)
- write_gcc_func_header(package, name, params, rets);
- else
- write_6g_func_header(package, name, params, paramwid, rets);
- bwritef(output, "#line %d \"%s\"\n", lineno, file);
-}
-
-/* Write out a function trailer. */
-static void
-write_func_trailer(char *package, char *name,
- struct params *rets)
-{
- if (gcc)
- write_gcc_func_trailer(package, name, rets);
- else
- write_6g_func_trailer(rets);
-}
-
-/*
- * Read and write the body of the function, ending in an unnested }
- * (which is read but not written).
- */
-static void
-copy_body(void)
-{
- int nesting = 0;
- while (1) {
- int c;
-
- c = getchar_no_eof();
- if (c == '}' && nesting == 0)
- return;
- xputchar(c);
- switch (c) {
- default:
- break;
- case '{':
- ++nesting;
- break;
- case '}':
- --nesting;
- break;
- case '/':
- c = getchar_update_lineno();
- xputchar(c);
- if (c == '/') {
- do {
- c = getchar_no_eof();
- xputchar(c);
- } while (c != '\n');
- } else if (c == '*') {
- while (1) {
- c = getchar_no_eof();
- xputchar(c);
- if (c == '*') {
- do {
- c = getchar_no_eof();
- xputchar(c);
- } while (c == '*');
- if (c == '/')
- break;
- }
- }
- }
- break;
- case '"':
- case '\'':
- {
- int delim = c;
- do {
- c = getchar_no_eof();
- xputchar(c);
- if (c == '\\') {
- c = getchar_no_eof();
- xputchar(c);
- c = '\0';
- }
- } while (c != delim);
- }
- break;
- }
- }
-}
-
-/* Process the entire file. */
-static void
-process_file(void)
-{
- char *package, *name, *p, *n;
- struct params *params, *rets;
- int paramwid;
-
- package = read_package();
- read_preprocessor_lines();
- while (read_func_header(&name, &params, &paramwid, &rets)) {
- // name may have a package override already
- n = xstrstr(name, "·");
- if(n != nil) {
- p = xmalloc(n - name + 1);
- xmemmove(p, name, n - name);
- p[n - name] = 0;
- n += xstrlen("·");
- } else {
- p = package;
- n = name;
- }
- write_func_header(p, n, params, paramwid, rets);
- copy_body();
- write_func_trailer(p, n, rets);
- xfree(name);
- if(p != package) xfree(p);
- free_params(params);
- free_params(rets);
- }
- xfree(package);
-}
-
-void
-goc2c(char *goc, char *c)
-{
- int i;
- Buf in, out;
-
- binit(&in);
- binit(&out);
-
- file = goc;
- readfile(&in, goc);
-
- // TODO: set gcc=1 when using gcc
-
- if(!gcc) {
- if(streq(goarch, "amd64")) {
- type_table[Uintptr].size = 8;
- if(use64bitint) {
- type_table[Int].size = 8;
- } else {
- type_table[Int].size = 4;
- }
- structround = 8;
- } else if(streq(goarch, "amd64p32")) {
- type_table[Uintptr].size = 4;
- type_table[Int].size = 4;
- structround = 8;
- } else {
- // NOTE: These are set in the initializer,
- // but they might have been changed by a
- // previous invocation of goc2c, so we have
- // to restore them.
- type_table[Uintptr].size = 4;
- type_table[Int].size = 4;
- structround = 4;
- }
-
- type_table[Uint].size = type_table[Int].size;
- type_table[Slice].size = type_table[Uintptr].size+2*type_table[Int].size;
- type_table[Eface].size = 2*type_table[Uintptr].size;
- type_table[String].size = 2*type_table[Uintptr].size;
-
- for(i=0; i<nelem(type_table); i++)
- type_table[i].rnd = type_table[i].size;
-
- type_table[String].rnd = type_table[Uintptr].rnd;
- type_table[Slice].rnd = type_table[Uintptr].rnd;
- type_table[Eface].rnd = type_table[Uintptr].rnd;
- type_table[Complex128].rnd = type_table[Float64].rnd;
- }
-
- bprintf(&out, "// auto generated by go tool dist\n// goos=%s goarch=%s\n\n", goos, goarch);
- input = bstr(&in);
- output = &out;
-
- lineno = 1;
- process_file();
-
- writefile(&out, c, 0);
-}
diff --git a/src/cmd/dist/plan9.c b/src/cmd/dist/plan9.c
index 8d492ebc6..e4bf25147 100644
--- a/src/cmd/dist/plan9.c
+++ b/src/cmd/dist/plan9.c
@@ -23,7 +23,7 @@ bprintf(Buf *b, char *fmt, ...)
{
va_list arg;
char buf[4096];
-
+
breset(b);
va_start(arg, fmt);
vsnprintf(buf, sizeof buf, fmt, arg);
@@ -572,10 +572,10 @@ bool
hassuffix(char *p, char *suffix)
{
int np, ns;
-
+
np = strlen(p);
ns = strlen(suffix);
- return np >= ns && strcmp(p+np-ns, suffix) == 0;
+ return np >= ns && streq(p+np-ns, suffix);
}
// hasprefix reports whether p begins with prefix.
diff --git a/src/cmd/dist/unix.c b/src/cmd/dist/unix.c
index 8b943a2d9..4a78684b4 100644
--- a/src/cmd/dist/unix.c
+++ b/src/cmd/dist/unix.c
@@ -431,7 +431,7 @@ xremoveall(char *p)
}
bfree(&b);
- vfree(&dir);
+ vfree(&dir);
}
// xreaddir replaces dst with a list of the names of the files in dir.
@@ -441,13 +441,13 @@ xreaddir(Vec *dst, char *dir)
{
DIR *d;
struct dirent *dp;
-
+
vreset(dst);
d = opendir(dir);
if(d == nil)
fatal("opendir %s: %s", dir, strerror(errno));
while((dp = readdir(d)) != nil) {
- if(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)
+ if(streq(dp->d_name, ".") || streq(dp->d_name, ".."))
continue;
vadd(dst, dp->d_name);
}
@@ -461,7 +461,7 @@ xworkdir(void)
{
Buf b;
char *p;
-
+
binit(&b);
xgetenv(&b, "TMPDIR");
@@ -546,10 +546,10 @@ bool
hassuffix(char *p, char *suffix)
{
int np, ns;
-
+
np = strlen(p);
ns = strlen(suffix);
- return np >= ns && strcmp(p+np-ns, suffix) == 0;
+ return np >= ns && streq(p+np-ns, suffix);
}
// hasprefix reports whether p begins with prefix.
@@ -712,7 +712,7 @@ main(int argc, char **argv)
fatal("unknown architecture: %s", u.machine);
}
- if(strcmp(gohostarch, "arm") == 0)
+ if(streq(gohostarch, "arm"))
maxnbg = 1;
// The OS X 10.6 linker does not support external linking mode.
@@ -724,7 +724,7 @@ main(int argc, char **argv)
//
// Roughly, OS X 10.N shows up as uname release (N+4),
// so OS X 10.6 is uname version 10 and OS X 10.8 is uname version 12.
- if(strcmp(gohostos, "darwin") == 0) {
+ if(streq(gohostos, "darwin")) {
if(uname(&u) < 0)
fatal("uname: %s", strerror(errno));
osx = atoi(u.release) - 4;
diff --git a/src/cmd/dist/windows.c b/src/cmd/dist/windows.c
index 2839c4bc5..ff1a27351 100644
--- a/src/cmd/dist/windows.c
+++ b/src/cmd/dist/windows.c
@@ -770,10 +770,10 @@ bool
hassuffix(char *p, char *suffix)
{
int np, ns;
-
+
np = strlen(p);
ns = strlen(suffix);
- return np >= ns && strcmp(p+np-ns, suffix) == 0;
+ return np >= ns && streq(p+np-ns, suffix);
}
bool
@@ -929,7 +929,7 @@ xsamefile(char *f1, char *f2)
return 1;
torune(&ru, f1);
- // refer to ../../pkg/os/stat_windows.go:/sameFile
+ // refer to ../../os/stat_windows.go:/sameFile
fd1 = CreateFileW(ru, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
xfree(ru);
if(fd1 == INVALID_HANDLE_VALUE)