summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-08-11 13:30:35 -0700
committerRob Pike <r@golang.org>2009-08-11 13:30:35 -0700
commit40e692180efc8fdff513ffce47f6fdb8463dc314 (patch)
treeb7de2e0a3cd37338607c7ddd50d6779e7099c747 /src
parent7b824c85c81f72a3ce76a4904ffe84f167322ca4 (diff)
downloadgolang-40e692180efc8fdff513ffce47f6fdb8463dc314.tar.gz
commentary about extern register
R=rsc DELTA=16 (12 added, 0 deleted, 4 changed) OCL=33030 CL=33035
Diffstat (limited to 'src')
-rw-r--r--src/pkg/runtime/runtime.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h
index 88e516139..c9b6a2611 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