diff options
author | Devon H. O'Dell <devon.odell@gmail.com> | 2009-11-17 23:58:51 -0800 |
---|---|---|
committer | Devon H. O'Dell <devon.odell@gmail.com> | 2009-11-17 23:58:51 -0800 |
commit | cba2fe2462fda1fe7b265f8056a89e6f6e06e938 (patch) | |
tree | 9f74efdaa20cae5f6501fd3fe6e50ced586dcfe9 /src/libcgo | |
parent | daab757a6fa77ff08a76fa1307a0c5f1f15e5c42 (diff) | |
download | golang-cba2fe2462fda1fe7b265f8056a89e6f6e06e938.tar.gz |
FreeBSD/i386 work
This patchset gets Go to pretty much the same state that
FreeBSD/amd64 is in.
R=rsc
http://codereview.appspot.com/157055
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/libcgo')
-rw-r--r-- | src/libcgo/freebsd_386.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/libcgo/freebsd_386.c b/src/libcgo/freebsd_386.c new file mode 100644 index 000000000..1f596f861 --- /dev/null +++ b/src/libcgo/freebsd_386.c @@ -0,0 +1,59 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include <pthread.h> +#include "libcgo.h" + +static void* threadentry(void*); +static pthread_key_t k1, k2; + +/* gccism: arrange for inittls to be called at dynamic load time */ +static void inittls(void) __attribute__((constructor)); + +static void +inittls(void) +{ + /* unimplemented for now */ +} + +void +initcgo(void) +{ +} + +void +libcgo_sys_thread_start(ThreadStart *ts) +{ + pthread_attr_t attr; + pthread_t p; + size_t size; + + pthread_attr_init(&attr); + pthread_attr_getstacksize(&attr, &size); + ts->g->stackguard = size; + pthread_create(&p, &attr, threadentry, ts); +} + +static void* +threadentry(void *v) +{ + ThreadStart ts; + + ts = *(ThreadStart*)v; + free(v); + + ts.g->stackbase = (uintptr)&ts; + + /* + * libcgo_sys_thread_start set stackguard to stack size; + * change to actual guard pointer. + */ + ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096; + + pthread_setspecific(k1, (void*)ts.g); + pthread_setspecific(k2, (void*)ts.m); + + crosscall_386(ts.fn); + return nil; +} |