diff options
author | Devon H. O'Dell <devon.odell@gmail.com> | 2009-11-17 08:20:58 -0800 |
---|---|---|
committer | Devon H. O'Dell <devon.odell@gmail.com> | 2009-11-17 08:20:58 -0800 |
commit | 429e86b5b7166734d6757e292b1548c39ff384bd (patch) | |
tree | 39fed3e2827dab53a5632cb0c69dc1e739c56076 /src/libcgo | |
parent | 92ba369b0adaa73e09b9b2764f821d234696df6b (diff) | |
download | golang-429e86b5b7166734d6757e292b1548c39ff384bd.tar.gz |
FreeBSD-specific porting work.
cgo/libmach remain unimplemented. However, compilers, runtime,
and packages are 100%. I still need to go through and implement
missing syscalls (at least make sure they're all listed), but
for all shipped functionality, this is done. Ship! ;)
R=rsc, VenkateshSrinivas
http://codereview.appspot.com/152142
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/libcgo')
-rw-r--r-- | src/libcgo/Makefile | 1 | ||||
-rw-r--r-- | src/libcgo/freebsd_amd64.c | 46 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/libcgo/Makefile b/src/libcgo/Makefile index 0cd19fbba..254e4622d 100644 --- a/src/libcgo/Makefile +++ b/src/libcgo/Makefile @@ -16,6 +16,7 @@ CFLAGS_amd64=-m64 LDFLAGS_linux=-shared -lpthread -lm LDFLAGS_darwin=-dynamiclib -Wl,-undefined,dynamic_lookup /usr/lib/libpthread.dylib +LDFLAGS_freebsd=-pthread -shared -lm %.o: %.c gcc $(CFLAGS_$(GOARCH)) -O2 -fPIC -o $@ -c $*.c diff --git a/src/libcgo/freebsd_amd64.c b/src/libcgo/freebsd_amd64.c new file mode 100644 index 000000000..14a409f5e --- /dev/null +++ b/src/libcgo/freebsd_amd64.c @@ -0,0 +1,46 @@ +// 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*); + +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; + + crosscall_amd64(ts.m, ts.g, ts.fn); + return nil; +} |