diff options
author | Russ Cox <rsc@golang.org> | 2014-08-29 16:00:31 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-08-29 16:00:31 -0400 |
commit | 8b0a1c7512ce245a9b8f9173cc9be021a42353f2 (patch) | |
tree | 846af318ad635880989710203aea35c5e938f8ba /src/cmd/dist | |
parent | bfaf5cfef53b75e5c72ec57d93da18ea2f0ed5d7 (diff) | |
download | go-8b0a1c7512ce245a9b8f9173cc9be021a42353f2.tar.gz |
runtime: include constants and defs_*_*.h types in generated Go defs
I had to rename Kevent and Sigaction to avoid the functions of the
same (lowercase) name.
LGTM=iant, r
R=golang-codereviews, r, iant, aram.h
CC=dvyukov, golang-codereviews, khr
https://codereview.appspot.com/140740043
Diffstat (limited to 'src/cmd/dist')
-rw-r--r-- | src/cmd/dist/buildruntime.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/cmd/dist/buildruntime.c b/src/cmd/dist/buildruntime.c index 5daa31494..2396e20c5 100644 --- a/src/cmd/dist/buildruntime.c +++ b/src/cmd/dist/buildruntime.c @@ -346,6 +346,10 @@ mkzruntimedefs(char *dir, char *file) "\n" ); + // Do not emit constant definitions for these. + vadd(&seen, "true"); + vadd(&seen, "false"); + vadd(&seen, "raceenabled"); // Run 6c -D GOOS_goos -D GOARCH_goarch -I workdir -q -n -o workdir/runtimedefs // on each of the runtimedefs C files. @@ -375,15 +379,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; @@ -394,6 +398,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; |