From d08f0067b5e5cfb4dbb437b6f4197d2bf4c8b7ca Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Tue, 11 Aug 2009 13:30:35 -0700 Subject: [PATCH] commentary about extern register R=rsc DELTA=16 (12 added, 0 deleted, 4 changed) OCL=33030 CL=33035 --- src/pkg/runtime/runtime.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index 88e5161392..c9b6a26118 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h @@ -64,10 +64,22 @@ typedef struct hash Hmap; typedef struct Hchan Hchan; /* - * per cpu declaration + * per-cpu declaration. + * "extern register" is a special storage class implemented by 6c, 8c, etc. + * on machines with lots of registers, it allocates a register that will not be + * used in generated code. on the x86, it allocates a slot indexed by a + * segment register. + * + * amd64: allocated downwards from R15 + * x86: allocated upwards from 0(FS) + * arm: allocated upwards from R9 + * + * every C file linked into a Go program must include runtime.h + * so that the C compiler knows to avoid other uses of these registers. + * the Go compilers know to avoid them. */ -extern register G* g; // R15 -extern register M* m; // R14 +extern register G* g; +extern register M* m; /* * defined constants -- 2.48.1