// Copyright 2012 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" /* * Helpers for building runtime. */ // mkzversion writes zversion.go: // // package runtime // const defaultGoroot = // const theVersion = // void mkzversion(char *dir, char *file) { Buf b, out; USED(dir); binit(&b); binit(&out); bwritestr(&out, bprintf(&b, "// auto generated by go tool dist\n" "\n" "package runtime\n" "\n" "const defaultGoroot = `%s`\n" "const theVersion = `%s`\n" "var buildVersion = theVersion\n", goroot_final, goversion)); writefile(&out, file, 0); bfree(&b); bfree(&out); } // mkzexperiment writes zaexperiment.h (sic): // // #define GOEXPERIMENT "experiment string" // void mkzexperiment(char *dir, char *file) { Buf b, out, exp; USED(dir); binit(&b); binit(&out); binit(&exp); xgetenv(&exp, "GOEXPERIMENT"); bwritestr(&out, bprintf(&b, "// auto generated by go tool dist\n" "\n" "#define GOEXPERIMENT \"%s\"\n", bstr(&exp))); writefile(&out, file, 0); bfree(&b); bfree(&out); bfree(&exp); } #define MAXWINCB 2000 /* maximum number of windows callbacks allowed */ // mkzsys writes zsys_$GOOS_$GOARCH.s, // which contains arch or os specific asm code. // void mkzsys(char *dir, char *file) { int i; Buf out; USED(dir); 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" "// execute Go implemented callback function. It is not\n" "// called from the start, instead runtime·compilecallback\n" "// always returns address into runtime·callbackasm offset\n" "// appropriately so different callbacks start with different\n" "// CALL instruction in runtime·callbackasm. This determines\n" "// which Go callback function is executed later on.\n" "TEXT runtime·callbackasm(SB),7,$0\n"); for(i=0; i