From 2c77ac0cd1a89e7966203f8f519a92fa19f0d66d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 5 Dec 2014 16:24:20 -0500 Subject: runtime: generate windows callback list with go generate This is the last system-dependent file written by cmd/dist. They are all now written by go generate. cmd/dist is not needed to start building package runtime for a different system anymore. Now all the generated files can be assumed generated, so delete the clumsy hacks in cmd/api. Re-enable api check in run.bash. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://codereview.appspot.com/185040044 --- src/cmd/api/goapi.go | 152 +-- src/cmd/dist/build.c | 19 +- src/cmd/dist/buildruntime.c | 41 - src/cmd/go/build.go | 3 +- src/run.bash | 3 +- src/run.bat | 6 +- src/runtime/runtime.go | 2 + src/runtime/wincallback.go | 43 + src/runtime/zcallback_windows.s | 2010 +++++++++++++++++++++++++++++++++++++++ 9 files changed, 2073 insertions(+), 206 deletions(-) create mode 100644 src/runtime/wincallback.go create mode 100644 src/runtime/zcallback_windows.s (limited to 'src') diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go index 5a8c87603..568aec8c0 100644 --- a/src/cmd/api/goapi.go +++ b/src/cmd/api/goapi.go @@ -352,139 +352,16 @@ var parsedFileCache = make(map[string]*ast.File) func (w *Walker) parseFile(dir, file string) (*ast.File, error) { filename := filepath.Join(dir, file) - f, _ := parsedFileCache[filename] - if f != nil { + if f := parsedFileCache[filename]; f != nil { return f, nil } - var err error - - // generate missing context-dependent files. - - if w.context != nil && file == fmt.Sprintf("zgoos_%s.go", w.context.GOOS) { - src := fmt.Sprintf("package runtime; const theGoos = `%s`", w.context.GOOS) - f, err = parser.ParseFile(fset, filename, src, 0) - if err != nil { - log.Fatalf("incorrect generated file: %s", err) - } - } - - if w.context != nil && file == fmt.Sprintf("zgoarch_%s.go", w.context.GOARCH) { - src := fmt.Sprintf("package runtime; const theGoarch = `%s`", w.context.GOARCH) - f, err = parser.ParseFile(fset, filename, src, 0) - if err != nil { - log.Fatalf("incorrect generated file: %s", err) - } - } - if w.context != nil && file == fmt.Sprintf("zruntime_defs_%s_%s.go", w.context.GOOS, w.context.GOARCH) { - // Just enough to keep the api checker happy. Keep sorted. - src := "package runtime; type (" + - " _defer struct{};" + - " _func struct{};" + - " _panic struct{};" + - " _select struct{}; " + - " _type struct{};" + - " alg struct{};" + - " chantype struct{};" + - " context struct{};" + // windows - " eface struct{};" + - " epollevent struct{};" + - " funcval struct{};" + - " g struct{};" + - " gobuf struct{};" + - " hchan struct{};" + - " iface struct{};" + - " interfacetype struct{};" + - " itab struct{};" + - " keventt struct{};" + - " m struct{};" + - " maptype struct{};" + - " mcache struct{};" + - " mspan struct{};" + - " mutex struct{};" + - " note struct{};" + - " p struct{};" + - " parfor struct{};" + - " slicetype struct{};" + - " stkframe struct{};" + - " sudog struct{};" + - " timespec struct{};" + - " waitq struct{};" + - " wincallbackcontext struct{};" + - "); " + - "const (" + - " cb_max = 2000;" + - " _CacheLineSize = 64;" + - " _Gidle = 1;" + - " _Grunnable = 2;" + - " _Grunning = 3;" + - " _Gsyscall = 4;" + - " _Gwaiting = 5;" + - " _Gdead = 6;" + - " _Genqueue = 7;" + - " _Gcopystack = 8;" + - " _NSIG = 32;" + - " _FlagNoScan = iota;" + - " _FlagNoZero;" + - " _TinySize;" + - " _TinySizeClass;" + - " _MaxSmallSize;" + - " _PageShift;" + - " _PageSize;" + - " _PageMask;" + - " _BitsPerPointer;" + - " _BitsMask;" + - " _PointersPerByte;" + - " _MaxGCMask;" + - " _BitsDead;" + - " _BitsPointer;" + - " _MSpanInUse;" + - " _ConcurrentSweep;" + - " _KindBool;" + - " _KindInt;" + - " _KindInt8;" + - " _KindInt16;" + - " _KindInt32;" + - " _KindInt64;" + - " _KindUint;" + - " _KindUint8;" + - " _KindUint16;" + - " _KindUint32;" + - " _KindUint64;" + - " _KindUintptr;" + - " _KindFloat32;" + - " _KindFloat64;" + - " _KindComplex64;" + - " _KindComplex128;" + - " _KindArray;" + - " _KindChan;" + - " _KindFunc;" + - " _KindInterface;" + - " _KindMap;" + - " _KindPtr;" + - " _KindSlice;" + - " _KindString;" + - " _KindStruct;" + - " _KindUnsafePointer;" + - " _KindDirectIface;" + - " _KindGCProg;" + - " _KindNoPointers;" + - " _KindMask;" + - ")" - f, err = parser.ParseFile(fset, filename, src, 0) - if err != nil { - log.Fatalf("incorrect generated file: %s", err) - } - } - - if f == nil { - f, err = parser.ParseFile(fset, filename, nil, 0) - if err != nil { - return nil, err - } + f, err := parser.ParseFile(fset, filename, nil, 0) + if err != nil { + return nil, err } - parsedFileCache[filename] = f + return f, nil } @@ -591,25 +468,6 @@ func (w *Walker) Import(name string) (pkg *types.Package) { filenames := append(append([]string{}, info.GoFiles...), info.CgoFiles...) - // Certain files only exist when building for the specified context. - // Add them manually. - if name == "runtime" { - n := fmt.Sprintf("zgoos_%s.go", w.context.GOOS) - if !contains(filenames, n) { - filenames = append(filenames, n) - } - - n = fmt.Sprintf("zgoarch_%s.go", w.context.GOARCH) - if !contains(filenames, n) { - filenames = append(filenames, n) - } - - n = fmt.Sprintf("zruntime_defs_%s_%s.go", w.context.GOOS, w.context.GOARCH) - if !contains(filenames, n) { - filenames = append(filenames, n) - } - } - // Parse package files. var files []*ast.File for _, file := range filenames { diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c index bfb3d15b8..3743b7300 100644 --- a/src/cmd/dist/build.c +++ b/src/cmd/dist/build.c @@ -588,9 +588,6 @@ static struct { }}, {"runtime", { "zaexperiment.h", - "zsys_$GOOS_$GOARCH.s", - "zgoarch_$GOARCH.go", - "zgoos_$GOOS.go", "zversion.go", }}, }; @@ -614,7 +611,6 @@ static struct { {"anames8.c", mkanames}, {"anames9.c", mkanames}, {"zdefaultcc.go", mkzdefaultcc}, - {"zsys_", mkzsys}, {"zversion.go", mkzversion}, {"zaexperiment.h", mkzexperiment}, @@ -1391,6 +1387,11 @@ static char *cleantab[] = { "unicode/utf8", }; +static char *runtimegen[] = { + "zaexperiment.h", + "zversion.go", +}; + static void clean(void) { @@ -1417,15 +1418,11 @@ clean(void) xremove(bpathf(&b, "%s/%s", bstr(&path), cleantab[i]+4)); } - // remove src/runtime/z* unconditionally, + // remove src/runtime/zaexperiment.h and // except leave zgoos and zgoarch, now maintained with go generate. - vreset(&dir); bpathf(&path, "%s/src/runtime", goroot); - xreaddir(&dir, bstr(&path)); - for(j=0; j