mirror of
https://github.com/golang/go
synced 2024-11-25 11:37:57 -07:00
More FreeBSD-touchups. Thundercats are GOOOOO!
R=rsc CC=golang-dev https://golang.org/cl/157074
This commit is contained in:
parent
eac41e7eba
commit
60b1a17b9e
@ -3,8 +3,6 @@
|
|||||||
# Use of this source code is governed by a BSD-style
|
# Use of this source code is governed by a BSD-style
|
||||||
# license that can be found in the LICENSE file.
|
# license that can be found in the LICENSE file.
|
||||||
|
|
||||||
if [ "$(uname)" = "FreeBSD" ]; then exit 0; fi
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
gomake hello fib chain
|
gomake hello fib chain
|
||||||
echo '*' hello >run.out
|
echo '*' hello >run.out
|
||||||
|
@ -150,10 +150,9 @@ main(int argc, char *argv[])
|
|||||||
if(strcmp(goos, "darwin") == 0)
|
if(strcmp(goos, "darwin") == 0)
|
||||||
HEADTYPE = 6;
|
HEADTYPE = 6;
|
||||||
else
|
else
|
||||||
if(strcmp(goos, "freebsd") == 0) {
|
if(strcmp(goos, "freebsd") == 0)
|
||||||
debug['d'] = 1; /* no dynamic syms for now */
|
|
||||||
HEADTYPE = 9;
|
HEADTYPE = 9;
|
||||||
} else
|
else
|
||||||
print("goos is not known: %s\n", goos);
|
print("goos is not known: %s\n", goos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,10 +158,9 @@ main(int argc, char *argv[])
|
|||||||
if(strcmp(goos, "nacl") == 0)
|
if(strcmp(goos, "nacl") == 0)
|
||||||
HEADTYPE = 8;
|
HEADTYPE = 8;
|
||||||
else
|
else
|
||||||
if(strcmp(goos, "freebsd") == 0) {
|
if(strcmp(goos, "freebsd") == 0)
|
||||||
debug['d'] = 1; /* no dynamic syms for now */
|
|
||||||
HEADTYPE = 9;
|
HEADTYPE = 9;
|
||||||
} else
|
else
|
||||||
print("goos is not known: %sn", goos);
|
print("goos is not known: %sn", goos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,10 +240,7 @@ main(int argc, char *argv[])
|
|||||||
* Also known to ../../pkg/runtime/linux/386/sys.s
|
* Also known to ../../pkg/runtime/linux/386/sys.s
|
||||||
* and ../../libcgo/linux_386.c.
|
* and ../../libcgo/linux_386.c.
|
||||||
*/
|
*/
|
||||||
if (HEADTYPE == 7)
|
tlsoffset = -8;
|
||||||
tlsoffset = -8;
|
|
||||||
else
|
|
||||||
tlsoffset = 0;
|
|
||||||
elfinit();
|
elfinit();
|
||||||
HEADR = ELFRESERVE;
|
HEADR = ELFRESERVE;
|
||||||
if(INITTEXT == -1)
|
if(INITTEXT == -1)
|
||||||
|
@ -6,15 +6,13 @@
|
|||||||
#include "libcgo.h"
|
#include "libcgo.h"
|
||||||
|
|
||||||
static void* threadentry(void*);
|
static void* threadentry(void*);
|
||||||
static pthread_key_t k1, k2;
|
|
||||||
|
|
||||||
/* gccism: arrange for inittls to be called at dynamic load time */
|
char *environ[] = { 0 };
|
||||||
static void inittls(void) __attribute__((constructor));
|
char *__progname;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inittls(void)
|
inittls(void)
|
||||||
{
|
{
|
||||||
/* unimplemented for now */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -51,8 +49,16 @@ threadentry(void *v)
|
|||||||
*/
|
*/
|
||||||
ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096;
|
ts.g->stackguard = (uintptr)&ts - ts.g->stackguard + 4096;
|
||||||
|
|
||||||
pthread_setspecific(k1, (void*)ts.g);
|
/*
|
||||||
pthread_setspecific(k2, (void*)ts.m);
|
* Set specific keys. On FreeBSD/ELF, the thread local storage
|
||||||
|
* is just before %gs:0. Our dynamic 8.out's reserve 8 bytes
|
||||||
|
* for the two words g and m at %gs:-8 and %gs:-4.
|
||||||
|
*/
|
||||||
|
asm volatile (
|
||||||
|
"movl %0, %%gs:-8\n" // MOVL g, -8(GS)
|
||||||
|
"movl %1, %%gs:-4\n" // MOVL m, -4(GS)
|
||||||
|
:: "r"(ts.g), "r"(ts.m)
|
||||||
|
);
|
||||||
|
|
||||||
crosscall_386(ts.fn);
|
crosscall_386(ts.fn);
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
static void* threadentry(void*);
|
static void* threadentry(void*);
|
||||||
|
|
||||||
|
char *environ[] = { 0 };
|
||||||
|
char *__progname;
|
||||||
|
|
||||||
void
|
void
|
||||||
initcgo(void)
|
initcgo(void)
|
||||||
{
|
{
|
||||||
|
@ -19,8 +19,8 @@ TEXT thr_new(SB),7,$-4
|
|||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT thr_start(SB),7,$0
|
TEXT thr_start(SB),7,$0
|
||||||
MOVL mm+0(FP), AX
|
MOVL mm+0(FP), AX
|
||||||
MOVL m_g0(AX), BX
|
MOVL m_g0(AX), BX
|
||||||
LEAL m_tls(AX), BP
|
LEAL m_tls(AX), BP
|
||||||
MOVL 0(BP), DI
|
MOVL 0(BP), DI
|
||||||
ADDL $7, DI
|
ADDL $7, DI
|
||||||
@ -132,7 +132,8 @@ int i386_set_ldt(int, const union ldt_entry *, int);
|
|||||||
// setldt(int entry, int address, int limit)
|
// setldt(int entry, int address, int limit)
|
||||||
TEXT setldt(SB),7,$32
|
TEXT setldt(SB),7,$32
|
||||||
MOVL address+4(FP), BX // aka base
|
MOVL address+4(FP), BX // aka base
|
||||||
MOVL limit+8(FP), CX
|
// see comment in linux/386/sys.s; freebsd is similar
|
||||||
|
ADDL $0x8, BX
|
||||||
|
|
||||||
// set up data_desc
|
// set up data_desc
|
||||||
LEAL 16(SP), AX // struct data_desc
|
LEAL 16(SP), AX // struct data_desc
|
||||||
@ -145,11 +146,8 @@ TEXT setldt(SB),7,$32
|
|||||||
SHRL $8, BX
|
SHRL $8, BX
|
||||||
MOVB BX, 7(AX)
|
MOVB BX, 7(AX)
|
||||||
|
|
||||||
MOVW CX, 0(AX)
|
MOVW $0xffff, 0(AX)
|
||||||
SHRL $16, CX
|
MOVB $0xCF, 6(AX) // 32-bit operand, 4k limit unit, 4 more bits of limit
|
||||||
ANDL $0x0F, CX
|
|
||||||
ORL $0x40, CX // 32-bit operand size
|
|
||||||
MOVB CX, 6(AX)
|
|
||||||
|
|
||||||
MOVB $0xF2, 5(AX) // r/w data descriptor, dpl=3, present
|
MOVB $0xF2, 5(AX) // r/w data descriptor, dpl=3, present
|
||||||
|
|
||||||
|
@ -385,6 +385,8 @@ starttheworld(void)
|
|||||||
void
|
void
|
||||||
mstart(void)
|
mstart(void)
|
||||||
{
|
{
|
||||||
|
if(g != m->g0)
|
||||||
|
throw("bad mstart");
|
||||||
if(m->mcache == nil)
|
if(m->mcache == nil)
|
||||||
m->mcache = allocmcache();
|
m->mcache = allocmcache();
|
||||||
minit();
|
minit();
|
||||||
|
Loading…
Reference in New Issue
Block a user