Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(842)

Delta Between Two Patch Sets: src/pkg/runtime/cgo/gcc_darwin_amd64.c

Issue 109050043: code review 109050043: all: remove 'extern register M *m' from runtime (Closed)
Left Patch Set: diff -r 7d2e78c502ab https://code.google.com/p/go/ Created 10 years, 9 months ago
Right Patch Set: diff -r 2699961d1143 https://code.google.com/p/go/ Created 10 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/cgo/gcc_darwin_386.c ('k') | src/pkg/runtime/cgo/gcc_dragonfly_386.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include <string.h> /* for strerror */ 5 #include <string.h> /* for strerror */
6 #include <pthread.h> 6 #include <pthread.h>
7 #include <signal.h> 7 #include <signal.h>
8 #include "libcgo.h" 8 #include "libcgo.h"
9 9
10 static void* threadentry(void*); 10 static void* threadentry(void*);
11 static pthread_key_t k1; 11 static pthread_key_t k1;
12 12
13 #define magic1 (0x23581321345589ULL) 13 #define magic1 (0x23581321345589ULL)
14 14
15 static void 15 static void
16 inittls(void) 16 inittls(void)
17 { 17 {
18 uint64 x; 18 uint64 x;
19 pthread_key_t tofree[128], k; 19 pthread_key_t tofree[128], k;
20 int i, ntofree; 20 int i, ntofree;
21 21
22 /* 22 /*
23 * Same logic, code as darwin_386.c:/inittls, except that words 23 * Same logic, code as darwin_386.c:/inittls, except that words
24 * are 8 bytes long now, and the thread-local storage starts 24 * are 8 bytes long now, and the thread-local storage starts
25 » * at 0x60 on Leopard / Snow Leopard. So the offsets are 25 » * at 0x60 on Leopard / Snow Leopard. So the offset is
26 » * 0x60+8*0x108 = 0x8a0 and 0x60+8*0x109 = 0x8a8. 26 » * 0x60+8*0x108 = 0x8a0.
27 * 27 *
28 » * The linker and runtime hard-code these constant offsets 28 » * The linker and runtime hard-code this constant offset
29 » * from %gs where we expect to find m and g. 29 » * from %gs where we expect to find g.
30 » * Known to ../../../cmd/6l/obj.c:/8a0 30 » * Known to ../../../liblink/sym.c:/8a0
31 * and to ../sys_darwin_amd64.s:/8a0 31 * and to ../sys_darwin_amd64.s:/8a0
32 * 32 *
33 * As disgusting as on the 386; same justification. 33 * As disgusting as on the 386; same justification.
34 */ 34 */
35 ntofree = 0; 35 ntofree = 0;
36 for(;;) { 36 for(;;) {
37 if(pthread_key_create(&k, nil) < 0) { 37 if(pthread_key_create(&k, nil) < 0) {
38 fprintf(stderr, "runtime/cgo: pthread_key_create failed\ n"); 38 fprintf(stderr, "runtime/cgo: pthread_key_create failed\ n");
39 abort(); 39 abort();
40 } 40 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 * _cgo_sys_thread_start set stackguard to stack size; 117 * _cgo_sys_thread_start set stackguard to stack size;
118 * change to actual guard pointer. 118 * change to actual guard pointer.
119 */ 119 */
120 ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096; 120 ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096;
121 121
122 pthread_setspecific(k1, (void*)ts.g); 122 pthread_setspecific(k1, (void*)ts.g);
123 123
124 crosscall_amd64(ts.fn); 124 crosscall_amd64(ts.fn);
125 return nil; 125 return nil;
126 } 126 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b