~ubuntu-branches/ubuntu/saucy/golang/saucy

« back to all changes in this revision

Viewing changes to src/pkg/runtime/cgo/gcc_linux_386.c

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-07-08 05:52:37 UTC
  • mfrom: (29.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130708055237-at01839e0hp8z3ni
Tags: 2:1.1-1ubuntu1
016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#include "libcgo.h"
9
9
 
10
10
static void *threadentry(void*);
 
11
static void (*setmg_gcc)(void*, void*);
11
12
 
12
 
static void
13
 
xinitcgo(G *g)
 
13
void
 
14
x_cgo_init(G *g, void (*setmg)(void*, void*))
14
15
{
15
16
        pthread_attr_t attr;
16
17
        size_t size;
17
18
 
 
19
        setmg_gcc = setmg;
18
20
        pthread_attr_init(&attr);
19
21
        pthread_attr_getstacksize(&attr, &size);
20
22
        g->stackguard = (uintptr)&attr - size + 4096;
21
23
        pthread_attr_destroy(&attr);
22
24
}
23
25
 
24
 
void (*initcgo)(G*) = xinitcgo;
25
26
 
26
27
void
27
 
libcgo_sys_thread_start(ThreadStart *ts)
 
28
_cgo_sys_thread_start(ThreadStart *ts)
28
29
{
29
30
        pthread_attr_t attr;
30
31
        sigset_t ign, oset;
64
65
        ts.g->stackbase = (uintptr)&ts;
65
66
 
66
67
        /*
67
 
         * libcgo_sys_thread_start set stackguard to stack size;
 
68
         * _cgo_sys_thread_start set stackguard to stack size;
68
69
         * change to actual guard pointer.
69
70
         */
70
71
        ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096;
71
72
 
72
73
        /*
73
 
         * Set specific keys.  On Linux/ELF, the thread local storage
74
 
         * is just before %gs:0.  Our dynamic 8.out's reserve 8 bytes
75
 
         * for the two words g and m at %gs:-8 and %gs:-4.
76
 
         * Xen requires us to access those words indirect from %gs:0
77
 
         * which points at itself.
 
74
         * Set specific keys.
78
75
         */
79
 
        asm volatile (
80
 
                "movl %%gs:0, %%eax\n"          // MOVL 0(GS), tmp
81
 
                "movl %0, -8(%%eax)\n"  // MOVL g, -8(GS)
82
 
                "movl %1, -4(%%eax)\n"  // MOVL m, -4(GS)
83
 
                :: "r"(ts.g), "r"(ts.m) : "%eax"
84
 
        );
 
76
        setmg_gcc((void*)ts.m, (void*)ts.g);
85
77
 
86
78
        crosscall_386(ts.fn);
87
79
        return nil;