mirror of
https://github.com/golang/go.git
synced 2025-11-11 22:21:06 +00:00
all: merge NaCl branch (part 1)
See golang.org/s/go13nacl for design overview. This CL is the mostly mechanical changes from rsc's Go 1.2 based NaCl branch, specifically 39cb35750369 to 500771b477cf from https://code.google.com/r/rsc-go13nacl. This CL does not include working NaCl support, there are probably two or three more large merges to come. CL 15750044 is not included as it involves more invasive changes to the linker which will need to be merged separately. The exact change lists included are 15050047: syscall: support for Native Client 15360044: syscall: unzip implementation for Native Client 15370044: syscall: Native Client SRPC implementation 15400047: cmd/dist, cmd/go, go/build, test: support for Native Client 15410048: runtime: support for Native Client 15410049: syscall: file descriptor table for Native Client 15410050: syscall: in-memory file system for Native Client 15440048: all: update +build lines for Native Client port 15540045: cmd/6g, cmd/8g, cmd/gc: support for Native Client 15570045: os: support for Native Client 15680044: crypto/..., hash/crc32, reflect, sync/atomic: support for amd64p32 15690044: net: support for Native Client 15690048: runtime: support for fake time like on Go Playground 15690051: build: disable various tests on Native Client LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/68150047
This commit is contained in:
parent
7206f50f71
commit
7c8280c9ef
133 changed files with 5747 additions and 142 deletions
|
|
@ -29,6 +29,7 @@ betypeinit(void)
|
|||
{
|
||||
widthptr = 4;
|
||||
widthint = 4;
|
||||
widthreg = 4;
|
||||
|
||||
zprog.link = P;
|
||||
zprog.as = AGOK;
|
||||
|
|
|
|||
|
|
@ -1417,23 +1417,23 @@ sgen(Node *n, Node *ns, int64 w)
|
|||
// reverse direction
|
||||
gins(ASTD, N, N); // set direction flag
|
||||
if(c > 0) {
|
||||
gconreg(AADDQ, w-1, D_SI);
|
||||
gconreg(AADDQ, w-1, D_DI);
|
||||
gconreg(addptr, w-1, D_SI);
|
||||
gconreg(addptr, w-1, D_DI);
|
||||
|
||||
gconreg(AMOVQ, c, D_CX);
|
||||
gconreg(movptr, c, D_CX);
|
||||
gins(AREP, N, N); // repeat
|
||||
gins(AMOVSB, N, N); // MOVB *(SI)-,*(DI)-
|
||||
}
|
||||
|
||||
if(q > 0) {
|
||||
if(c > 0) {
|
||||
gconreg(AADDQ, -7, D_SI);
|
||||
gconreg(AADDQ, -7, D_DI);
|
||||
gconreg(addptr, -7, D_SI);
|
||||
gconreg(addptr, -7, D_DI);
|
||||
} else {
|
||||
gconreg(AADDQ, w-8, D_SI);
|
||||
gconreg(AADDQ, w-8, D_DI);
|
||||
gconreg(addptr, w-8, D_SI);
|
||||
gconreg(addptr, w-8, D_DI);
|
||||
}
|
||||
gconreg(AMOVQ, q, D_CX);
|
||||
gconreg(movptr, q, D_CX);
|
||||
gins(AREP, N, N); // repeat
|
||||
gins(AMOVSQ, N, N); // MOVQ *(SI)-,*(DI)-
|
||||
}
|
||||
|
|
@ -1442,7 +1442,7 @@ sgen(Node *n, Node *ns, int64 w)
|
|||
} else {
|
||||
// normal direction
|
||||
if(q >= 4) {
|
||||
gconreg(AMOVQ, q, D_CX);
|
||||
gconreg(movptr, q, D_CX);
|
||||
gins(AREP, N, N); // repeat
|
||||
gins(AMOVSQ, N, N); // MOVQ *(SI)+,*(DI)+
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@ LinkArch* thelinkarch = &linkamd64;
|
|||
|
||||
vlong MAXWIDTH = 1LL<<50;
|
||||
|
||||
int addptr = AADDQ;
|
||||
int movptr = AMOVQ;
|
||||
int leaptr = ALEAQ;
|
||||
int stosptr = ASTOSQ;
|
||||
int cmpptr = ACMPQ;
|
||||
|
||||
/*
|
||||
* go declares several platform-specific type aliases:
|
||||
* int, uint, float, and uintptr
|
||||
|
|
@ -29,6 +35,20 @@ betypeinit(void)
|
|||
{
|
||||
widthptr = 8;
|
||||
widthint = 8;
|
||||
widthreg = 8;
|
||||
if(strcmp(getgoarch(), "amd64p32") == 0) {
|
||||
widthptr = 4;
|
||||
widthint = 4;
|
||||
addptr = AADDL;
|
||||
movptr = AMOVL;
|
||||
leaptr = ALEAL;
|
||||
stosptr = ASTOSL;
|
||||
cmpptr = ACMPL;
|
||||
typedefs[0].sameas = TINT32;
|
||||
typedefs[1].sameas = TUINT32;
|
||||
typedefs[2].sameas = TUINT32;
|
||||
|
||||
}
|
||||
|
||||
zprog.link = P;
|
||||
zprog.as = AGOK;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,14 @@ EXTERN Node* deferproc;
|
|||
EXTERN Node* deferreturn;
|
||||
EXTERN Node* panicindex;
|
||||
EXTERN Node* panicslice;
|
||||
EXTERN Node* panicdiv;
|
||||
EXTERN Node* throwreturn;
|
||||
extern vlong unmappedzero;
|
||||
extern int addptr;
|
||||
extern int cmpptr;
|
||||
extern int movptr;
|
||||
extern int leaptr;
|
||||
extern int stosptr;
|
||||
|
||||
/*
|
||||
* ggen.c
|
||||
|
|
|
|||
|
|
@ -180,17 +180,21 @@ ginscall(Node *f, int proc)
|
|||
|
||||
case 1: // call in new proc (go)
|
||||
case 2: // deferred call (defer)
|
||||
nodreg(®, types[TINT64], D_CX);
|
||||
if(flag_largemodel) {
|
||||
regalloc(&r1, f->type, f);
|
||||
nodconst(&con, types[TINT64], argsize(f->type));
|
||||
if(widthptr == 4) {
|
||||
nodreg(&r1, types[TINT32], D_CX);
|
||||
gmove(f, &r1);
|
||||
gins(APUSHQ, &r1, N);
|
||||
regfree(&r1);
|
||||
nodreg(®, types[TINT64], D_CX);
|
||||
nodconst(&r1, types[TINT64], 32);
|
||||
gins(ASHLQ, &r1, ®);
|
||||
gins(AORQ, &con, ®);
|
||||
gins(APUSHQ, ®, N);
|
||||
} else {
|
||||
gins(APUSHQ, f, N);
|
||||
}
|
||||
nodconst(&con, types[TINT32], argsize(f->type));
|
||||
nodreg(®, types[TINT64], D_CX);
|
||||
gmove(f, ®);
|
||||
gins(APUSHQ, ®, N);
|
||||
gins(APUSHQ, &con, N);
|
||||
}
|
||||
if(proc == 1)
|
||||
ginscall(newproc, 0);
|
||||
else {
|
||||
|
|
@ -198,7 +202,9 @@ ginscall(Node *f, int proc)
|
|||
fatal("hasdefer=0 but has defer");
|
||||
ginscall(deferproc, 0);
|
||||
}
|
||||
nodreg(®, types[TINT64], D_CX);
|
||||
gins(APOPQ, N, ®);
|
||||
if(widthptr == 8)
|
||||
gins(APOPQ, N, ®);
|
||||
if(proc == 2) {
|
||||
nodreg(®, types[TINT64], D_AX);
|
||||
|
|
@ -387,11 +393,11 @@ cgen_aret(Node *n, Node *res)
|
|||
|
||||
if(res->op != OREGISTER) {
|
||||
regalloc(&nod2, types[tptr], res);
|
||||
gins(ALEAQ, &nod1, &nod2);
|
||||
gins(AMOVQ, &nod2, res);
|
||||
gins(leaptr, &nod1, &nod2);
|
||||
gins(movptr, &nod2, res);
|
||||
regfree(&nod2);
|
||||
} else
|
||||
gins(ALEAQ, &nod1, res);
|
||||
gins(leaptr, &nod1, res);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -634,6 +640,18 @@ dodiv(int op, Node *nl, Node *nr, Node *res)
|
|||
}
|
||||
|
||||
p2 = P;
|
||||
if(nacl) {
|
||||
// Native Client does not relay the divide-by-zero trap
|
||||
// to the executing program, so we must insert a check
|
||||
// for ourselves.
|
||||
nodconst(&n4, t, 0);
|
||||
gins(optoas(OCMP, t), &n3, &n4);
|
||||
p1 = gbranch(optoas(ONE, t), T, +1);
|
||||
if(panicdiv == N)
|
||||
panicdiv = sysfunc("panicdivide");
|
||||
ginscall(panicdiv, -1);
|
||||
patch(p1, pc);
|
||||
}
|
||||
if(check) {
|
||||
nodconst(&n4, t, -1);
|
||||
gins(optoas(OCMP, t), &n3, &n4);
|
||||
|
|
@ -1045,10 +1063,10 @@ clearfat(Node *nl)
|
|||
agen(nl, &n1);
|
||||
|
||||
savex(D_AX, &ax, &oldax, N, types[tptr]);
|
||||
gconreg(AMOVQ, 0, D_AX);
|
||||
gconreg(AMOVL, 0, D_AX);
|
||||
|
||||
if(q >= 4) {
|
||||
gconreg(AMOVQ, q, D_CX);
|
||||
gconreg(movptr, q, D_CX);
|
||||
gins(AREP, N, N); // repeat
|
||||
gins(ASTOSQ, N, N); // STOQ AL,*(DI)+
|
||||
} else
|
||||
|
|
@ -1111,7 +1129,7 @@ expandchecks(Prog *firstp)
|
|||
p2->lineno = p->lineno;
|
||||
p1->pc = 9999;
|
||||
p2->pc = 9999;
|
||||
p->as = ACMPQ;
|
||||
p->as = cmpptr;
|
||||
p->to.type = D_CONST;
|
||||
p->to.offset = 0;
|
||||
p1->as = AJNE;
|
||||
|
|
|
|||
|
|
@ -296,6 +296,11 @@ ginit(void)
|
|||
|
||||
for(i=0; i<nelem(resvd); i++)
|
||||
reg[resvd[i]]++;
|
||||
|
||||
if(nacl) {
|
||||
reg[D_BP]++;
|
||||
reg[D_R15]++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -305,6 +310,11 @@ gclean(void)
|
|||
|
||||
for(i=0; i<nelem(resvd); i++)
|
||||
reg[resvd[i]]--;
|
||||
if(nacl) {
|
||||
reg[D_BP]--;
|
||||
reg[D_R15]--;
|
||||
}
|
||||
|
||||
|
||||
for(i=D_AX; i<=D_R15; i++)
|
||||
if(reg[i])
|
||||
|
|
@ -520,7 +530,16 @@ gconreg(int as, vlong c, int reg)
|
|||
{
|
||||
Node nr;
|
||||
|
||||
switch(as) {
|
||||
case AADDL:
|
||||
case AMOVL:
|
||||
case ALEAL:
|
||||
nodreg(&nr, types[TINT32], reg);
|
||||
break;
|
||||
default:
|
||||
nodreg(&nr, types[TINT64], reg);
|
||||
}
|
||||
|
||||
ginscon(as, c, &nr);
|
||||
}
|
||||
|
||||
|
|
@ -533,10 +552,18 @@ ginscon(int as, vlong c, Node *n2)
|
|||
{
|
||||
Node n1, ntmp;
|
||||
|
||||
switch(as) {
|
||||
case AADDL:
|
||||
case AMOVL:
|
||||
case ALEAL:
|
||||
nodconst(&n1, types[TINT32], c);
|
||||
break;
|
||||
default:
|
||||
nodconst(&n1, types[TINT64], c);
|
||||
}
|
||||
|
||||
if(as != AMOVQ && (c < -(1LL<<31) || c >= 1LL<<31)) {
|
||||
// cannot have 64-bit immediokate in ADD, etc.
|
||||
// cannot have 64-bit immediate in ADD, etc.
|
||||
// instead, MOV into register first.
|
||||
regalloc(&ntmp, types[TINT64], N);
|
||||
gins(AMOVQ, &n1, &ntmp);
|
||||
|
|
@ -2040,7 +2067,7 @@ odot:
|
|||
for(i=1; i<o; i++) {
|
||||
if(oary[i] >= 0)
|
||||
fatal("can't happen");
|
||||
gins(AMOVQ, &n1, reg);
|
||||
gins(movptr, &n1, reg);
|
||||
cgen_checknil(reg);
|
||||
n1.xoffset = -(oary[i]+1);
|
||||
}
|
||||
|
|
@ -2252,7 +2279,7 @@ oindex_const_sudo:
|
|||
if(reg->op == OEMPTY)
|
||||
regalloc(reg, types[tptr], N);
|
||||
|
||||
p1 = gins(AMOVQ, N, reg);
|
||||
p1 = gins(movptr, N, reg);
|
||||
p1->from = *a;
|
||||
|
||||
n2 = *reg;
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ static ProgInfo progtable[ALAST] = {
|
|||
|
||||
[AJMP]= {Jump | Break | KillCarry},
|
||||
|
||||
[ALEAL]= {LeftAddr | RightWrite},
|
||||
[ALEAQ]= {LeftAddr | RightWrite},
|
||||
|
||||
[AMOVBLSX]= {SizeL | LeftRead | RightWrite | Conv},
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ addmove(Reg *r, int bn, int rn, int f)
|
|||
// need to clean this up with wptr and
|
||||
// some of the defaults
|
||||
p1->as = AMOVL;
|
||||
switch(v->etype) {
|
||||
switch(simtype[(uchar)v->etype]) {
|
||||
default:
|
||||
fatal("unknown type %E", v->etype);
|
||||
case TINT8:
|
||||
|
|
@ -501,7 +501,6 @@ addmove(Reg *r, int bn, int rn, int f)
|
|||
break;
|
||||
case TINT64:
|
||||
case TUINT64:
|
||||
case TUINTPTR:
|
||||
case TPTR64:
|
||||
p1->as = AMOVQ;
|
||||
break;
|
||||
|
|
@ -511,8 +510,6 @@ addmove(Reg *r, int bn, int rn, int f)
|
|||
case TFLOAT64:
|
||||
p1->as = AMOVSD;
|
||||
break;
|
||||
case TINT:
|
||||
case TUINT:
|
||||
case TINT32:
|
||||
case TUINT32:
|
||||
case TPTR32:
|
||||
|
|
@ -1088,6 +1085,8 @@ int
|
|||
BtoR(int32 b)
|
||||
{
|
||||
b &= 0xffffL;
|
||||
if(nacl)
|
||||
b &= ~((1<<(D_BP-D_AX)) | (1<<(D_R15-D_AX)));
|
||||
if(b == 0)
|
||||
return 0;
|
||||
return bitno(b) + D_AX;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ betypeinit(void)
|
|||
{
|
||||
widthptr = 4;
|
||||
widthint = 4;
|
||||
widthreg = 4;
|
||||
|
||||
zprog.link = P;
|
||||
zprog.as = AGOK;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ EXTERN Node* deferproc;
|
|||
EXTERN Node* deferreturn;
|
||||
EXTERN Node* panicindex;
|
||||
EXTERN Node* panicslice;
|
||||
EXTERN Node* panicdiv;
|
||||
EXTERN Node* throwreturn;
|
||||
EXTERN int maxstksize;
|
||||
extern uint32 unmappedzero;
|
||||
|
|
|
|||
|
|
@ -664,6 +664,18 @@ dodiv(int op, Node *nl, Node *nr, Node *res, Node *ax, Node *dx)
|
|||
gmove(&t2, &n1);
|
||||
gmove(&t1, ax);
|
||||
p2 = P;
|
||||
if(nacl) {
|
||||
// Native Client does not relay the divide-by-zero trap
|
||||
// to the executing program, so we must insert a check
|
||||
// for ourselves.
|
||||
nodconst(&n4, t, 0);
|
||||
gins(optoas(OCMP, t), &n1, &n4);
|
||||
p1 = gbranch(optoas(ONE, t), T, +1);
|
||||
if(panicdiv == N)
|
||||
panicdiv = sysfunc("panicdivide");
|
||||
ginscall(panicdiv, -1);
|
||||
patch(p1, pc);
|
||||
}
|
||||
if(check) {
|
||||
nodconst(&n4, t, -1);
|
||||
gins(optoas(OCMP, t), &n1, &n4);
|
||||
|
|
|
|||
4
src/cmd/dist/build.c
vendored
4
src/cmd/dist/build.c
vendored
|
|
@ -38,13 +38,14 @@ static void dopack(char*, char*, char**, int);
|
|||
static char *findgoversion(void);
|
||||
|
||||
// The known architecture letters.
|
||||
static char *gochars = "568";
|
||||
static char *gochars = "5668";
|
||||
|
||||
// The known architectures.
|
||||
static char *okgoarch[] = {
|
||||
// same order as gochars
|
||||
"arm",
|
||||
"amd64",
|
||||
"amd64p32",
|
||||
"386",
|
||||
};
|
||||
|
||||
|
|
@ -55,6 +56,7 @@ static char *okgoos[] = {
|
|||
"linux",
|
||||
"solaris",
|
||||
"freebsd",
|
||||
"nacl",
|
||||
"netbsd",
|
||||
"openbsd",
|
||||
"plan9",
|
||||
|
|
|
|||
|
|
@ -175,11 +175,11 @@ dowidth(Type *t)
|
|||
case TFLOAT64:
|
||||
case TCOMPLEX64:
|
||||
w = 8;
|
||||
t->align = widthptr;
|
||||
t->align = widthreg;
|
||||
break;
|
||||
case TCOMPLEX128:
|
||||
w = 16;
|
||||
t->align = widthptr;
|
||||
t->align = widthreg;
|
||||
break;
|
||||
case TPTR32:
|
||||
w = 4;
|
||||
|
|
@ -288,10 +288,10 @@ dowidth(Type *t)
|
|||
// compute their widths as side-effect.
|
||||
t1 = t->type;
|
||||
w = widstruct(t->type, *getthis(t1), 0, 0);
|
||||
w = widstruct(t->type, *getinarg(t1), w, widthptr);
|
||||
w = widstruct(t->type, *getoutarg(t1), w, widthptr);
|
||||
w = widstruct(t->type, *getinarg(t1), w, widthreg);
|
||||
w = widstruct(t->type, *getoutarg(t1), w, widthreg);
|
||||
t1->argwid = w;
|
||||
if(w%widthptr)
|
||||
if(w%widthreg)
|
||||
warn("bad type %T %d\n", t1, w);
|
||||
t->align = 1;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ char *runtimeimport =
|
|||
"func @\"\".new (@\"\".typ·2 *byte) (? *any)\n"
|
||||
"func @\"\".panicindex ()\n"
|
||||
"func @\"\".panicslice ()\n"
|
||||
"func @\"\".panicdivide ()\n"
|
||||
"func @\"\".throwreturn ()\n"
|
||||
"func @\"\".throwinit ()\n"
|
||||
"func @\"\".panicwrap (? string, ? string, ? string)\n"
|
||||
|
|
|
|||
|
|
@ -950,6 +950,7 @@ EXTERN Node* curfn;
|
|||
|
||||
EXTERN int widthptr;
|
||||
EXTERN int widthint;
|
||||
EXTERN int widthreg;
|
||||
|
||||
EXTERN Node* typesw;
|
||||
EXTERN Node* nblank;
|
||||
|
|
@ -982,6 +983,8 @@ EXTERN int writearchive;
|
|||
|
||||
EXTERN Biobuf bstdout;
|
||||
|
||||
EXTERN int nacl;
|
||||
|
||||
/*
|
||||
* y.tab.c
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -258,7 +258,17 @@ main(int argc, char *argv[])
|
|||
|
||||
goroot = getgoroot();
|
||||
goos = getgoos();
|
||||
goarch = thestring;
|
||||
|
||||
// Allow GOARCH=thestring or GOARCH=thestringsuffix,
|
||||
// but not other values.
|
||||
p = getgoarch();
|
||||
if(strncmp(p, thestring, strlen(thestring)) != 0)
|
||||
fatal("cannot use %cg with GOARCH=%s", thechar, p);
|
||||
goarch = p;
|
||||
|
||||
nacl = strcmp(goos, "nacl") == 0;
|
||||
if(nacl)
|
||||
flag_largemodel = 1;
|
||||
|
||||
setexp();
|
||||
|
||||
|
|
@ -779,7 +789,7 @@ importfile(Val *f, int line)
|
|||
yyerror("import %s: not a go object file", file);
|
||||
errorexit();
|
||||
}
|
||||
q = smprint("%s %s %s %s", getgoos(), thestring, getgoversion(), expstring());
|
||||
q = smprint("%s %s %s %s", getgoos(), getgoarch(), getgoversion(), expstring());
|
||||
if(strcmp(p+10, q) != 0) {
|
||||
yyerror("import %s: object is [%s] expected [%s]", file, p+10, q);
|
||||
errorexit();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ dumpobj(void)
|
|||
Bwrite(bout, arhdr, sizeof arhdr);
|
||||
startobj = Boffset(bout);
|
||||
}
|
||||
Bprint(bout, "go object %s %s %s %s\n", getgoos(), thestring, getgoversion(), expstring());
|
||||
Bprint(bout, "go object %s %s %s %s\n", getgoos(), getgoarch(), getgoversion(), expstring());
|
||||
dumpexport();
|
||||
|
||||
if(writearchive) {
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ allocauto(Prog* ptxt)
|
|||
}
|
||||
n->stkdelta = -stksize - n->xoffset;
|
||||
}
|
||||
stksize = rnd(stksize, widthptr);
|
||||
stksize = rnd(stksize, widthreg);
|
||||
stkptrsize = rnd(stkptrsize, widthptr);
|
||||
stkzerosize = rnd(stkzerosize, widthptr);
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,11 @@ mapbucket(Type *t)
|
|||
overflowfield->sym->name = "overflow";
|
||||
offset += widthptr;
|
||||
|
||||
// The keys are padded to the native integer alignment.
|
||||
// This is usually the same as widthptr; the exception (as usual) is nacl/amd64.
|
||||
if(widthreg > widthptr)
|
||||
offset += widthreg - widthptr;
|
||||
|
||||
keysfield = typ(TFIELD);
|
||||
keysfield->type = typ(TARRAY);
|
||||
keysfield->type->type = keytype;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ package PACKAGE
|
|||
func new(typ *byte) *any
|
||||
func panicindex()
|
||||
func panicslice()
|
||||
func panicdivide()
|
||||
func throwreturn()
|
||||
func throwinit()
|
||||
func panicwrap(string, string, string)
|
||||
|
|
|
|||
|
|
@ -1059,7 +1059,7 @@ walkexpr(Node **np, NodeList **init)
|
|||
switch(n->op) {
|
||||
case OMOD:
|
||||
case ODIV:
|
||||
if(widthptr > 4 || (et != TUINT64 && et != TINT64))
|
||||
if(widthreg >= 8 || (et != TUINT64 && et != TINT64))
|
||||
goto ret;
|
||||
if(et == TINT64)
|
||||
strcpy(namebuf, "int64");
|
||||
|
|
|
|||
|
|
@ -204,6 +204,9 @@ type stringsFlag []string
|
|||
func (v *stringsFlag) Set(s string) error {
|
||||
var err error
|
||||
*v, err = splitQuotedFields(s)
|
||||
if *v == nil {
|
||||
*v = []string{}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,27 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var execCmd []string // -exec flag, for run and test
|
||||
|
||||
func findExecCmd() []string {
|
||||
if execCmd != nil {
|
||||
return execCmd
|
||||
}
|
||||
execCmd = []string{} // avoid work the second time
|
||||
if goos == runtime.GOOS && goarch == runtime.GOARCH {
|
||||
return execCmd
|
||||
}
|
||||
path, err := exec.LookPath(fmt.Sprintf("go_%s_%s_exec", goos, goarch))
|
||||
if err == nil {
|
||||
execCmd = []string{path}
|
||||
}
|
||||
return execCmd
|
||||
}
|
||||
|
||||
var cmdRun = &Command{
|
||||
UsageLine: "run [build flags] gofiles... [arguments...]",
|
||||
Short: "compile and run Go program",
|
||||
|
|
@ -28,6 +46,7 @@ func init() {
|
|||
cmdRun.Run = runRun // break init loop
|
||||
|
||||
addBuildFlags(cmdRun)
|
||||
cmdRun.Flag.Var((*stringsFlag)(&execCmd), "exec", "")
|
||||
}
|
||||
|
||||
func printStderr(args ...interface{}) (int, error) {
|
||||
|
|
@ -90,20 +109,20 @@ func runRun(cmd *Command, args []string) {
|
|||
// runProgram is the action for running a binary that has already
|
||||
// been compiled. We ignore exit status.
|
||||
func (b *builder) runProgram(a *action) error {
|
||||
cmdline := stringList(findExecCmd(), a.deps[0].target, a.args)
|
||||
if buildN || buildX {
|
||||
b.showcmd("", "%s %s", a.deps[0].target, strings.Join(a.args, " "))
|
||||
b.showcmd("", "%s", strings.Join(cmdline, " "))
|
||||
if buildN {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
runStdin(a.deps[0].target, a.args)
|
||||
runStdin(cmdline)
|
||||
return nil
|
||||
}
|
||||
|
||||
// runStdin is like run, but connects Stdin.
|
||||
func runStdin(cmdargs ...interface{}) {
|
||||
cmdline := stringList(cmdargs...)
|
||||
func runStdin(cmdline []string) {
|
||||
cmd := exec.Command(cmdline[0], cmdline[1:]...)
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package main
|
||||
|
||||
|
|
|
|||
|
|
@ -293,6 +293,8 @@ func runTest(cmd *Command, args []string) {
|
|||
var pkgArgs []string
|
||||
pkgArgs, testArgs = testFlags(args)
|
||||
|
||||
findExecCmd() // initialize cached result
|
||||
|
||||
raceInit()
|
||||
pkgs := packagesForBuild(pkgArgs)
|
||||
if len(pkgs) == 0 {
|
||||
|
|
@ -835,7 +837,7 @@ func declareCoverVars(importPath string, files ...string) map[string]*CoverVar {
|
|||
|
||||
// runTest is the action for running a test binary.
|
||||
func (b *builder) runTest(a *action) error {
|
||||
args := stringList(a.deps[0].target, testArgs)
|
||||
args := stringList(findExecCmd(), a.deps[0].target, testArgs)
|
||||
a.testOutput = new(bytes.Buffer)
|
||||
|
||||
if buildN || buildX {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ var testFlagDefn = []*testFlagSpec{
|
|||
{name: "x", boolVar: &buildX},
|
||||
{name: "work", boolVar: &buildWork},
|
||||
{name: "gcflags"},
|
||||
{name: "exec"},
|
||||
{name: "ldflags"},
|
||||
{name: "gccgoflags"},
|
||||
{name: "tags"},
|
||||
|
|
@ -154,6 +155,11 @@ func testFlags(args []string) (packageNames, passToTest []string) {
|
|||
setBoolFlag(f.boolVar, value)
|
||||
case "p":
|
||||
setIntFlag(&buildP, value)
|
||||
case "exec":
|
||||
execCmd, err = splitQuotedFields(value)
|
||||
if err != nil {
|
||||
fatalf("invalid flag argument for -%s: %v", f.name, err)
|
||||
}
|
||||
case "gcflags":
|
||||
buildGcflags, err = splitQuotedFields(value)
|
||||
if err != nil {
|
||||
|
|
|
|||
184
src/pkg/crypto/md5/md5block_amd64p32.s
Normal file
184
src/pkg/crypto/md5/md5block_amd64p32.s
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
// Original source:
|
||||
// http://www.zorinaq.com/papers/md5-amd64.html
|
||||
// http://www.zorinaq.com/papers/md5-amd64.tar.bz2
|
||||
//
|
||||
// Translated from Perl generating GNU assembly into
|
||||
// #defines generating 6a assembly by the Go Authors.
|
||||
//
|
||||
// Restrictions to make code safe for Native Client:
|
||||
// replace BP with R11, reloaded before use at return.
|
||||
// replace R15 with R11.
|
||||
|
||||
#include "../../../cmd/ld/textflag.h"
|
||||
|
||||
// MD5 optimized for AMD64.
|
||||
//
|
||||
// Author: Marc Bevand <bevand_m (at) epita.fr>
|
||||
// Licence: I hereby disclaim the copyright on this code and place it
|
||||
// in the public domain.
|
||||
|
||||
TEXT ·block(SB),NOSPLIT,$0-32
|
||||
MOVL dig+0(FP), R11
|
||||
MOVL p+4(FP), SI
|
||||
MOVL p_len+8(FP), DX
|
||||
SHRQ $6, DX
|
||||
SHLQ $6, DX
|
||||
|
||||
LEAQ (SI)(DX*1), DI
|
||||
MOVL (0*4)(R11), AX
|
||||
MOVL (1*4)(R11), BX
|
||||
MOVL (2*4)(R11), CX
|
||||
MOVL (3*4)(R11), DX
|
||||
|
||||
CMPQ SI, DI
|
||||
JEQ end
|
||||
|
||||
loop:
|
||||
MOVL AX, R12
|
||||
MOVL BX, R13
|
||||
MOVL CX, R14
|
||||
MOVL DX, R11
|
||||
|
||||
MOVL (0*4)(SI), R8
|
||||
MOVL DX, R9
|
||||
|
||||
#define ROUND1(a, b, c, d, index, const, shift) \
|
||||
XORL c, R9; \
|
||||
LEAL const(a)(R8*1), a; \
|
||||
ANDL b, R9; \
|
||||
XORL d, R9; \
|
||||
MOVL (index*4)(SI), R8; \
|
||||
ADDL R9, a; \
|
||||
ROLL $shift, a; \
|
||||
MOVL c, R9; \
|
||||
ADDL b, a
|
||||
|
||||
ROUND1(AX,BX,CX,DX, 1,0xd76aa478, 7);
|
||||
ROUND1(DX,AX,BX,CX, 2,0xe8c7b756,12);
|
||||
ROUND1(CX,DX,AX,BX, 3,0x242070db,17);
|
||||
ROUND1(BX,CX,DX,AX, 4,0xc1bdceee,22);
|
||||
ROUND1(AX,BX,CX,DX, 5,0xf57c0faf, 7);
|
||||
ROUND1(DX,AX,BX,CX, 6,0x4787c62a,12);
|
||||
ROUND1(CX,DX,AX,BX, 7,0xa8304613,17);
|
||||
ROUND1(BX,CX,DX,AX, 8,0xfd469501,22);
|
||||
ROUND1(AX,BX,CX,DX, 9,0x698098d8, 7);
|
||||
ROUND1(DX,AX,BX,CX,10,0x8b44f7af,12);
|
||||
ROUND1(CX,DX,AX,BX,11,0xffff5bb1,17);
|
||||
ROUND1(BX,CX,DX,AX,12,0x895cd7be,22);
|
||||
ROUND1(AX,BX,CX,DX,13,0x6b901122, 7);
|
||||
ROUND1(DX,AX,BX,CX,14,0xfd987193,12);
|
||||
ROUND1(CX,DX,AX,BX,15,0xa679438e,17);
|
||||
ROUND1(BX,CX,DX,AX, 0,0x49b40821,22);
|
||||
|
||||
MOVL (1*4)(SI), R8
|
||||
MOVL DX, R9
|
||||
MOVL DX, R10
|
||||
|
||||
#define ROUND2(a, b, c, d, index, const, shift) \
|
||||
NOTL R9; \
|
||||
LEAL const(a)(R8*1),a; \
|
||||
ANDL b, R10; \
|
||||
ANDL c, R9; \
|
||||
MOVL (index*4)(SI),R8; \
|
||||
ORL R9, R10; \
|
||||
MOVL c, R9; \
|
||||
ADDL R10, a; \
|
||||
MOVL c, R10; \
|
||||
ROLL $shift, a; \
|
||||
ADDL b, a
|
||||
|
||||
ROUND2(AX,BX,CX,DX, 6,0xf61e2562, 5);
|
||||
ROUND2(DX,AX,BX,CX,11,0xc040b340, 9);
|
||||
ROUND2(CX,DX,AX,BX, 0,0x265e5a51,14);
|
||||
ROUND2(BX,CX,DX,AX, 5,0xe9b6c7aa,20);
|
||||
ROUND2(AX,BX,CX,DX,10,0xd62f105d, 5);
|
||||
ROUND2(DX,AX,BX,CX,15, 0x2441453, 9);
|
||||
ROUND2(CX,DX,AX,BX, 4,0xd8a1e681,14);
|
||||
ROUND2(BX,CX,DX,AX, 9,0xe7d3fbc8,20);
|
||||
ROUND2(AX,BX,CX,DX,14,0x21e1cde6, 5);
|
||||
ROUND2(DX,AX,BX,CX, 3,0xc33707d6, 9);
|
||||
ROUND2(CX,DX,AX,BX, 8,0xf4d50d87,14);
|
||||
ROUND2(BX,CX,DX,AX,13,0x455a14ed,20);
|
||||
ROUND2(AX,BX,CX,DX, 2,0xa9e3e905, 5);
|
||||
ROUND2(DX,AX,BX,CX, 7,0xfcefa3f8, 9);
|
||||
ROUND2(CX,DX,AX,BX,12,0x676f02d9,14);
|
||||
ROUND2(BX,CX,DX,AX, 0,0x8d2a4c8a,20);
|
||||
|
||||
MOVL (5*4)(SI), R8
|
||||
MOVL CX, R9
|
||||
|
||||
#define ROUND3(a, b, c, d, index, const, shift) \
|
||||
LEAL const(a)(R8*1),a; \
|
||||
MOVL (index*4)(SI),R8; \
|
||||
XORL d, R9; \
|
||||
XORL b, R9; \
|
||||
ADDL R9, a; \
|
||||
ROLL $shift, a; \
|
||||
MOVL b, R9; \
|
||||
ADDL b, a
|
||||
|
||||
ROUND3(AX,BX,CX,DX, 8,0xfffa3942, 4);
|
||||
ROUND3(DX,AX,BX,CX,11,0x8771f681,11);
|
||||
ROUND3(CX,DX,AX,BX,14,0x6d9d6122,16);
|
||||
ROUND3(BX,CX,DX,AX, 1,0xfde5380c,23);
|
||||
ROUND3(AX,BX,CX,DX, 4,0xa4beea44, 4);
|
||||
ROUND3(DX,AX,BX,CX, 7,0x4bdecfa9,11);
|
||||
ROUND3(CX,DX,AX,BX,10,0xf6bb4b60,16);
|
||||
ROUND3(BX,CX,DX,AX,13,0xbebfbc70,23);
|
||||
ROUND3(AX,BX,CX,DX, 0,0x289b7ec6, 4);
|
||||
ROUND3(DX,AX,BX,CX, 3,0xeaa127fa,11);
|
||||
ROUND3(CX,DX,AX,BX, 6,0xd4ef3085,16);
|
||||
ROUND3(BX,CX,DX,AX, 9, 0x4881d05,23);
|
||||
ROUND3(AX,BX,CX,DX,12,0xd9d4d039, 4);
|
||||
ROUND3(DX,AX,BX,CX,15,0xe6db99e5,11);
|
||||
ROUND3(CX,DX,AX,BX, 2,0x1fa27cf8,16);
|
||||
ROUND3(BX,CX,DX,AX, 0,0xc4ac5665,23);
|
||||
|
||||
MOVL (0*4)(SI), R8
|
||||
MOVL $0xffffffff, R9
|
||||
XORL DX, R9
|
||||
|
||||
#define ROUND4(a, b, c, d, index, const, shift) \
|
||||
LEAL const(a)(R8*1),a; \
|
||||
ORL b, R9; \
|
||||
XORL c, R9; \
|
||||
ADDL R9, a; \
|
||||
MOVL (index*4)(SI),R8; \
|
||||
MOVL $0xffffffff, R9; \
|
||||
ROLL $shift, a; \
|
||||
XORL c, R9; \
|
||||
ADDL b, a
|
||||
|
||||
ROUND4(AX,BX,CX,DX, 7,0xf4292244, 6);
|
||||
ROUND4(DX,AX,BX,CX,14,0x432aff97,10);
|
||||
ROUND4(CX,DX,AX,BX, 5,0xab9423a7,15);
|
||||
ROUND4(BX,CX,DX,AX,12,0xfc93a039,21);
|
||||
ROUND4(AX,BX,CX,DX, 3,0x655b59c3, 6);
|
||||
ROUND4(DX,AX,BX,CX,10,0x8f0ccc92,10);
|
||||
ROUND4(CX,DX,AX,BX, 1,0xffeff47d,15);
|
||||
ROUND4(BX,CX,DX,AX, 8,0x85845dd1,21);
|
||||
ROUND4(AX,BX,CX,DX,15,0x6fa87e4f, 6);
|
||||
ROUND4(DX,AX,BX,CX, 6,0xfe2ce6e0,10);
|
||||
ROUND4(CX,DX,AX,BX,13,0xa3014314,15);
|
||||
ROUND4(BX,CX,DX,AX, 4,0x4e0811a1,21);
|
||||
ROUND4(AX,BX,CX,DX,11,0xf7537e82, 6);
|
||||
ROUND4(DX,AX,BX,CX, 2,0xbd3af235,10);
|
||||
ROUND4(CX,DX,AX,BX, 9,0x2ad7d2bb,15);
|
||||
ROUND4(BX,CX,DX,AX, 0,0xeb86d391,21);
|
||||
|
||||
ADDL R12, AX
|
||||
ADDL R13, BX
|
||||
ADDL R14, CX
|
||||
ADDL R11, DX
|
||||
|
||||
ADDQ $64, SI
|
||||
CMPQ SI, DI
|
||||
JB loop
|
||||
|
||||
end:
|
||||
MOVL dig+0(FP), R11
|
||||
MOVL AX, (0*4)(R11)
|
||||
MOVL BX, (1*4)(R11)
|
||||
MOVL CX, (2*4)(R11)
|
||||
MOVL DX, (3*4)(R11)
|
||||
RET
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build amd64 386 arm
|
||||
// +build amd64 amd64p32 386 arm
|
||||
|
||||
package md5
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd plan9 solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris
|
||||
|
||||
// Unix cryptographically secure pseudorandom number
|
||||
// generator.
|
||||
|
|
|
|||
192
src/pkg/crypto/rc4/rc4_amd64p32.s
Normal file
192
src/pkg/crypto/rc4/rc4_amd64p32.s
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
// Original source:
|
||||
// http://www.zorinaq.com/papers/rc4-amd64.html
|
||||
// http://www.zorinaq.com/papers/rc4-amd64.tar.bz2
|
||||
|
||||
#include "../../../cmd/ld/textflag.h"
|
||||
|
||||
// Local modifications:
|
||||
//
|
||||
// Transliterated from GNU to 6a assembly syntax by the Go authors.
|
||||
// The comments and spacing are from the original.
|
||||
//
|
||||
// The new EXTEND macros avoid a bad stall on some systems after 8-bit math.
|
||||
//
|
||||
// The original code accumulated 64 bits of key stream in an integer
|
||||
// register and then XOR'ed the key stream into the data 8 bytes at a time.
|
||||
// Modified to accumulate 128 bits of key stream into an XMM register
|
||||
// and then XOR the key stream into the data 16 bytes at a time.
|
||||
// Approximately doubles throughput.
|
||||
//
|
||||
// Converted to amd64p32.
|
||||
//
|
||||
// To make safe for Native Client, avoid use of BP, R15,
|
||||
// and two-register addressing modes.
|
||||
|
||||
// NOTE: Changing EXTEND to a no-op makes the code run 1.2x faster on Core i5
|
||||
// but makes the code run 2.0x slower on Xeon.
|
||||
#define EXTEND(r) MOVBLZX r, r
|
||||
|
||||
/*
|
||||
** RC4 implementation optimized for AMD64.
|
||||
**
|
||||
** Author: Marc Bevand <bevand_m (at) epita.fr>
|
||||
** Licence: I hereby disclaim the copyright on this code and place it
|
||||
** in the public domain.
|
||||
**
|
||||
** The code has been designed to be easily integrated into openssl:
|
||||
** the exported RC4() function can replace the actual implementations
|
||||
** openssl already contains. Please note that when linking with openssl,
|
||||
** it requires that sizeof(RC4_INT) == 8. So openssl must be compiled
|
||||
** with -DRC4_INT='unsigned long'.
|
||||
**
|
||||
** The throughput achieved by this code is about 320 MBytes/sec, on
|
||||
** a 1.8 GHz AMD Opteron (rev C0) processor.
|
||||
*/
|
||||
|
||||
TEXT ·xorKeyStream(SB),NOSPLIT,$0
|
||||
MOVL n+8(FP), BX // rbx = ARG(len)
|
||||
MOVL src+4(FP), SI // in = ARG(in)
|
||||
MOVL dst+0(FP), DI // out = ARG(out)
|
||||
MOVL state+12(FP), R10 // d = ARG(data)
|
||||
MOVL i+16(FP), AX
|
||||
MOVBQZX 0(AX), CX // x = *xp
|
||||
MOVL j+20(FP), AX
|
||||
MOVBQZX 0(AX), DX // y = *yp
|
||||
|
||||
LEAQ (SI)(BX*1), R9 // limit = in+len
|
||||
|
||||
l1: CMPQ SI, R9 // cmp in with in+len
|
||||
JGE finished // jump if (in >= in+len)
|
||||
|
||||
INCB CX
|
||||
EXTEND(CX)
|
||||
TESTL $15, CX
|
||||
JZ wordloop
|
||||
LEAL (R10)(CX*4), R12
|
||||
|
||||
MOVBLZX (R12), AX
|
||||
|
||||
ADDB AX, DX // y += tx
|
||||
EXTEND(DX)
|
||||
LEAL (R10)(DX*4), R11
|
||||
MOVBLZX (R11), BX // ty = d[y]
|
||||
MOVB BX, (R12) // d[x] = ty
|
||||
ADDB AX, BX // val = ty+tx
|
||||
EXTEND(BX)
|
||||
LEAL (R10)(BX*4), R13
|
||||
MOVB AX, (R11) // d[y] = tx
|
||||
MOVBLZX (R13), R8 // val = d[val]
|
||||
XORB (SI), R8 // xor 1 byte
|
||||
MOVB R8, (DI)
|
||||
INCQ SI // in++
|
||||
INCQ DI // out++
|
||||
JMP l1
|
||||
|
||||
wordloop:
|
||||
SUBQ $16, R9
|
||||
CMPQ SI, R9
|
||||
JGT end
|
||||
|
||||
start:
|
||||
ADDQ $16, SI // increment in
|
||||
ADDQ $16, DI // increment out
|
||||
|
||||
// Each KEYROUND generates one byte of key and
|
||||
// inserts it into an XMM register at the given 16-bit index.
|
||||
// The key state array is uint32 words only using the bottom
|
||||
// byte of each word, so the 16-bit OR only copies 8 useful bits.
|
||||
// We accumulate alternating bytes into X0 and X1, and then at
|
||||
// the end we OR X1<<8 into X0 to produce the actual key.
|
||||
//
|
||||
// At the beginning of the loop, CX%16 == 0, so the 16 loads
|
||||
// at state[CX], state[CX+1], ..., state[CX+15] can precompute
|
||||
// (state+CX) as R12 and then become R12[0], R12[1], ... R12[15],
|
||||
// without fear of the byte computation CX+15 wrapping around.
|
||||
//
|
||||
// The first round needs R12[0], the second needs R12[1], and so on.
|
||||
// We can avoid memory stalls by starting the load for round n+1
|
||||
// before the end of round n, using the LOAD macro.
|
||||
LEAQ (R10)(CX*4), R12
|
||||
|
||||
#define KEYROUND(xmm, load, off, r1, r2, index) \
|
||||
LEAL (R10)(DX*4), R11; \
|
||||
MOVBLZX (R11), R8; \
|
||||
MOVB r1, (R11); \
|
||||
load((off+1), r2); \
|
||||
MOVB R8, (off*4)(R12); \
|
||||
ADDB r1, R8; \
|
||||
EXTEND(R8); \
|
||||
LEAL (R10)(R8*4), R14; \
|
||||
PINSRW $index, (R14), xmm
|
||||
|
||||
#define LOAD(off, reg) \
|
||||
MOVBLZX (off*4)(R12), reg; \
|
||||
ADDB reg, DX; \
|
||||
EXTEND(DX)
|
||||
|
||||
#define SKIP(off, reg)
|
||||
|
||||
LOAD(0, AX)
|
||||
KEYROUND(X0, LOAD, 0, AX, BX, 0)
|
||||
KEYROUND(X1, LOAD, 1, BX, AX, 0)
|
||||
KEYROUND(X0, LOAD, 2, AX, BX, 1)
|
||||
KEYROUND(X1, LOAD, 3, BX, AX, 1)
|
||||
KEYROUND(X0, LOAD, 4, AX, BX, 2)
|
||||
KEYROUND(X1, LOAD, 5, BX, AX, 2)
|
||||
KEYROUND(X0, LOAD, 6, AX, BX, 3)
|
||||
KEYROUND(X1, LOAD, 7, BX, AX, 3)
|
||||
KEYROUND(X0, LOAD, 8, AX, BX, 4)
|
||||
KEYROUND(X1, LOAD, 9, BX, AX, 4)
|
||||
KEYROUND(X0, LOAD, 10, AX, BX, 5)
|
||||
KEYROUND(X1, LOAD, 11, BX, AX, 5)
|
||||
KEYROUND(X0, LOAD, 12, AX, BX, 6)
|
||||
KEYROUND(X1, LOAD, 13, BX, AX, 6)
|
||||
KEYROUND(X0, LOAD, 14, AX, BX, 7)
|
||||
KEYROUND(X1, SKIP, 15, BX, AX, 7)
|
||||
|
||||
ADDB $16, CX
|
||||
|
||||
PSLLQ $8, X1
|
||||
PXOR X1, X0
|
||||
MOVOU -16(SI), X2
|
||||
PXOR X0, X2
|
||||
MOVOU X2, -16(DI)
|
||||
|
||||
CMPQ SI, R9 // cmp in with in+len-16
|
||||
JLE start // jump if (in <= in+len-16)
|
||||
|
||||
end:
|
||||
DECB CX
|
||||
ADDQ $16, R9 // tmp = in+len
|
||||
|
||||
// handle the last bytes, one by one
|
||||
l2: CMPQ SI, R9 // cmp in with in+len
|
||||
JGE finished // jump if (in >= in+len)
|
||||
|
||||
INCB CX
|
||||
EXTEND(CX)
|
||||
LEAL (R10)(CX*4), R12
|
||||
MOVBLZX (R12), AX
|
||||
|
||||
ADDB AX, DX // y += tx
|
||||
EXTEND(DX)
|
||||
LEAL (R10)(DX*4), R11
|
||||
MOVBLZX (R11), BX // ty = d[y]
|
||||
MOVB BX, (R12) // d[x] = ty
|
||||
ADDB AX, BX // val = ty+tx
|
||||
EXTEND(BX)
|
||||
LEAL (R10)(BX*4), R13
|
||||
MOVB AX, (R11) // d[y] = tx
|
||||
MOVBLZX (R13), R8 // val = d[val]
|
||||
XORB (SI), R8 // xor 1 byte
|
||||
MOVB R8, (DI)
|
||||
INCQ SI // in++
|
||||
INCQ DI // out++
|
||||
JMP l2
|
||||
|
||||
finished:
|
||||
MOVL j+20(FP), BX
|
||||
MOVB DX, 0(BX)
|
||||
MOVL i+16(FP), AX
|
||||
MOVB CX, 0(AX)
|
||||
RET
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build amd64 arm 386
|
||||
// +build amd64 amd64p32 arm 386
|
||||
|
||||
package rc4
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !amd64,!arm,!386
|
||||
// +build !amd64,!amd64p32,!arm,!386
|
||||
|
||||
package rc4
|
||||
|
||||
|
|
|
|||
216
src/pkg/crypto/sha1/sha1block_amd64p32.s
Normal file
216
src/pkg/crypto/sha1/sha1block_amd64p32.s
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
// Copyright 2013 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 "../../../cmd/ld/textflag.h"
|
||||
|
||||
// SHA1 block routine. See sha1block.go for Go equivalent.
|
||||
//
|
||||
// There are 80 rounds of 4 types:
|
||||
// - rounds 0-15 are type 1 and load data (ROUND1 macro).
|
||||
// - rounds 16-19 are type 1 and do not load data (ROUND1x macro).
|
||||
// - rounds 20-39 are type 2 and do not load data (ROUND2 macro).
|
||||
// - rounds 40-59 are type 3 and do not load data (ROUND3 macro).
|
||||
// - rounds 60-79 are type 4 and do not load data (ROUND4 macro).
|
||||
//
|
||||
// Each round loads or shuffles the data, then computes a per-round
|
||||
// function of b, c, d, and then mixes the result into and rotates the
|
||||
// five registers a, b, c, d, e holding the intermediate results.
|
||||
//
|
||||
// The register rotation is implemented by rotating the arguments to
|
||||
// the round macros instead of by explicit move instructions.
|
||||
//
|
||||
// amd64p32 version.
|
||||
// To ensure safety for Native Client, avoids use of BP and R15
|
||||
// as well as two-register addressing modes.
|
||||
|
||||
#define LOAD(index) \
|
||||
MOVL (index*4)(SI), R10; \
|
||||
BSWAPL R10; \
|
||||
MOVL R10, (index*4)(SP)
|
||||
|
||||
#define SHUFFLE(index) \
|
||||
MOVL (((index)&0xf)*4)(SP), R10; \
|
||||
XORL (((index-3)&0xf)*4)(SP), R10; \
|
||||
XORL (((index-8)&0xf)*4)(SP), R10; \
|
||||
XORL (((index-14)&0xf)*4)(SP), R10; \
|
||||
ROLL $1, R10; \
|
||||
MOVL R10, (((index)&0xf)*4)(SP)
|
||||
|
||||
#define FUNC1(a, b, c, d, e) \
|
||||
MOVL d, R9; \
|
||||
XORL c, R9; \
|
||||
ANDL b, R9; \
|
||||
XORL d, R9
|
||||
|
||||
#define FUNC2(a, b, c, d, e) \
|
||||
MOVL b, R9; \
|
||||
XORL c, R9; \
|
||||
XORL d, R9
|
||||
|
||||
#define FUNC3(a, b, c, d, e) \
|
||||
MOVL b, R8; \
|
||||
ORL c, R8; \
|
||||
ANDL d, R8; \
|
||||
MOVL b, R9; \
|
||||
ANDL c, R9; \
|
||||
ORL R8, R9
|
||||
|
||||
#define FUNC4 FUNC2
|
||||
|
||||
#define MIX(a, b, c, d, e, const) \
|
||||
ROLL $30, b; \
|
||||
ADDL R9, e; \
|
||||
MOVL a, R8; \
|
||||
ROLL $5, R8; \
|
||||
LEAL const(e)(R10*1), e; \
|
||||
ADDL R8, e
|
||||
|
||||
#define ROUND1(a, b, c, d, e, index) \
|
||||
LOAD(index); \
|
||||
FUNC1(a, b, c, d, e); \
|
||||
MIX(a, b, c, d, e, 0x5A827999)
|
||||
|
||||
#define ROUND1x(a, b, c, d, e, index) \
|
||||
SHUFFLE(index); \
|
||||
FUNC1(a, b, c, d, e); \
|
||||
MIX(a, b, c, d, e, 0x5A827999)
|
||||
|
||||
#define ROUND2(a, b, c, d, e, index) \
|
||||
SHUFFLE(index); \
|
||||
FUNC2(a, b, c, d, e); \
|
||||
MIX(a, b, c, d, e, 0x6ED9EBA1)
|
||||
|
||||
#define ROUND3(a, b, c, d, e, index) \
|
||||
SHUFFLE(index); \
|
||||
FUNC3(a, b, c, d, e); \
|
||||
MIX(a, b, c, d, e, 0x8F1BBCDC)
|
||||
|
||||
#define ROUND4(a, b, c, d, e, index) \
|
||||
SHUFFLE(index); \
|
||||
FUNC4(a, b, c, d, e); \
|
||||
MIX(a, b, c, d, e, 0xCA62C1D6)
|
||||
|
||||
TEXT ·block(SB),NOSPLIT,$64-32
|
||||
MOVL dig+0(FP), R14
|
||||
MOVL p_base+4(FP), SI
|
||||
MOVL p_len+8(FP), DX
|
||||
SHRQ $6, DX
|
||||
SHLQ $6, DX
|
||||
|
||||
LEAQ (SI)(DX*1), DI
|
||||
MOVL (0*4)(R14), AX
|
||||
MOVL (1*4)(R14), BX
|
||||
MOVL (2*4)(R14), CX
|
||||
MOVL (3*4)(R14), DX
|
||||
MOVL (4*4)(R14), R13
|
||||
|
||||
CMPQ SI, DI
|
||||
JEQ end
|
||||
|
||||
loop:
|
||||
#define BP R13 /* keep diff from sha1block_amd64.s small */
|
||||
ROUND1(AX, BX, CX, DX, BP, 0)
|
||||
ROUND1(BP, AX, BX, CX, DX, 1)
|
||||
ROUND1(DX, BP, AX, BX, CX, 2)
|
||||
ROUND1(CX, DX, BP, AX, BX, 3)
|
||||
ROUND1(BX, CX, DX, BP, AX, 4)
|
||||
ROUND1(AX, BX, CX, DX, BP, 5)
|
||||
ROUND1(BP, AX, BX, CX, DX, 6)
|
||||
ROUND1(DX, BP, AX, BX, CX, 7)
|
||||
ROUND1(CX, DX, BP, AX, BX, 8)
|
||||
ROUND1(BX, CX, DX, BP, AX, 9)
|
||||
ROUND1(AX, BX, CX, DX, BP, 10)
|
||||
ROUND1(BP, AX, BX, CX, DX, 11)
|
||||
ROUND1(DX, BP, AX, BX, CX, 12)
|
||||
ROUND1(CX, DX, BP, AX, BX, 13)
|
||||
ROUND1(BX, CX, DX, BP, AX, 14)
|
||||
ROUND1(AX, BX, CX, DX, BP, 15)
|
||||
|
||||
ROUND1x(BP, AX, BX, CX, DX, 16)
|
||||
ROUND1x(DX, BP, AX, BX, CX, 17)
|
||||
ROUND1x(CX, DX, BP, AX, BX, 18)
|
||||
ROUND1x(BX, CX, DX, BP, AX, 19)
|
||||
|
||||
ROUND2(AX, BX, CX, DX, BP, 20)
|
||||
ROUND2(BP, AX, BX, CX, DX, 21)
|
||||
ROUND2(DX, BP, AX, BX, CX, 22)
|
||||
ROUND2(CX, DX, BP, AX, BX, 23)
|
||||
ROUND2(BX, CX, DX, BP, AX, 24)
|
||||
ROUND2(AX, BX, CX, DX, BP, 25)
|
||||
ROUND2(BP, AX, BX, CX, DX, 26)
|
||||
ROUND2(DX, BP, AX, BX, CX, 27)
|
||||
ROUND2(CX, DX, BP, AX, BX, 28)
|
||||
ROUND2(BX, CX, DX, BP, AX, 29)
|
||||
ROUND2(AX, BX, CX, DX, BP, 30)
|
||||
ROUND2(BP, AX, BX, CX, DX, 31)
|
||||
ROUND2(DX, BP, AX, BX, CX, 32)
|
||||
ROUND2(CX, DX, BP, AX, BX, 33)
|
||||
ROUND2(BX, CX, DX, BP, AX, 34)
|
||||
ROUND2(AX, BX, CX, DX, BP, 35)
|
||||
ROUND2(BP, AX, BX, CX, DX, 36)
|
||||
ROUND2(DX, BP, AX, BX, CX, 37)
|
||||
ROUND2(CX, DX, BP, AX, BX, 38)
|
||||
ROUND2(BX, CX, DX, BP, AX, 39)
|
||||
|
||||
ROUND3(AX, BX, CX, DX, BP, 40)
|
||||
ROUND3(BP, AX, BX, CX, DX, 41)
|
||||
ROUND3(DX, BP, AX, BX, CX, 42)
|
||||
ROUND3(CX, DX, BP, AX, BX, 43)
|
||||
ROUND3(BX, CX, DX, BP, AX, 44)
|
||||
ROUND3(AX, BX, CX, DX, BP, 45)
|
||||
ROUND3(BP, AX, BX, CX, DX, 46)
|
||||
ROUND3(DX, BP, AX, BX, CX, 47)
|
||||
ROUND3(CX, DX, BP, AX, BX, 48)
|
||||
ROUND3(BX, CX, DX, BP, AX, 49)
|
||||
ROUND3(AX, BX, CX, DX, BP, 50)
|
||||
ROUND3(BP, AX, BX, CX, DX, 51)
|
||||
ROUND3(DX, BP, AX, BX, CX, 52)
|
||||
ROUND3(CX, DX, BP, AX, BX, 53)
|
||||
ROUND3(BX, CX, DX, BP, AX, 54)
|
||||
ROUND3(AX, BX, CX, DX, BP, 55)
|
||||
ROUND3(BP, AX, BX, CX, DX, 56)
|
||||
ROUND3(DX, BP, AX, BX, CX, 57)
|
||||
ROUND3(CX, DX, BP, AX, BX, 58)
|
||||
ROUND3(BX, CX, DX, BP, AX, 59)
|
||||
|
||||
ROUND4(AX, BX, CX, DX, BP, 60)
|
||||
ROUND4(BP, AX, BX, CX, DX, 61)
|
||||
ROUND4(DX, BP, AX, BX, CX, 62)
|
||||
ROUND4(CX, DX, BP, AX, BX, 63)
|
||||
ROUND4(BX, CX, DX, BP, AX, 64)
|
||||
ROUND4(AX, BX, CX, DX, BP, 65)
|
||||
ROUND4(BP, AX, BX, CX, DX, 66)
|
||||
ROUND4(DX, BP, AX, BX, CX, 67)
|
||||
ROUND4(CX, DX, BP, AX, BX, 68)
|
||||
ROUND4(BX, CX, DX, BP, AX, 69)
|
||||
ROUND4(AX, BX, CX, DX, BP, 70)
|
||||
ROUND4(BP, AX, BX, CX, DX, 71)
|
||||
ROUND4(DX, BP, AX, BX, CX, 72)
|
||||
ROUND4(CX, DX, BP, AX, BX, 73)
|
||||
ROUND4(BX, CX, DX, BP, AX, 74)
|
||||
ROUND4(AX, BX, CX, DX, BP, 75)
|
||||
ROUND4(BP, AX, BX, CX, DX, 76)
|
||||
ROUND4(DX, BP, AX, BX, CX, 77)
|
||||
ROUND4(CX, DX, BP, AX, BX, 78)
|
||||
ROUND4(BX, CX, DX, BP, AX, 79)
|
||||
#undef BP
|
||||
|
||||
ADDL (0*4)(R14), AX
|
||||
ADDL (1*4)(R14), BX
|
||||
ADDL (2*4)(R14), CX
|
||||
ADDL (3*4)(R14), DX
|
||||
ADDL (4*4)(R14), R13
|
||||
|
||||
MOVL AX, (0*4)(R14)
|
||||
MOVL BX, (1*4)(R14)
|
||||
MOVL CX, (2*4)(R14)
|
||||
MOVL DX, (3*4)(R14)
|
||||
MOVL R13, (4*4)(R14)
|
||||
|
||||
ADDQ $64, SI
|
||||
CMPQ SI, DI
|
||||
JB loop
|
||||
|
||||
end:
|
||||
RET
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build amd64 386 arm
|
||||
// +build amd64 amd64p32 386
|
||||
|
||||
package sha1
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build dragonfly freebsd linux openbsd netbsd solaris
|
||||
// +build dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package x509
|
||||
|
||||
|
|
|
|||
|
|
@ -1209,7 +1209,7 @@ func ArchChar(goarch string) (string, error) {
|
|||
switch goarch {
|
||||
case "386":
|
||||
return "8", nil
|
||||
case "amd64":
|
||||
case "amd64", "amd64p32":
|
||||
return "6", nil
|
||||
case "arm":
|
||||
return "5", nil
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
package build
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -359,7 +360,7 @@ func allowed(pkg string) map[string]bool {
|
|||
}
|
||||
|
||||
var bools = []bool{false, true}
|
||||
var geese = []string{"darwin", "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "plan9", "solaris", "windows"}
|
||||
var geese = []string{"darwin", "dragonfly", "freebsd", "linux", "nacl", "netbsd", "openbsd", "plan9", "solaris", "windows"}
|
||||
var goarches = []string{"386", "amd64", "arm"}
|
||||
|
||||
type osPkg struct {
|
||||
|
|
@ -374,6 +375,11 @@ var allowedErrors = map[osPkg]bool{
|
|||
}
|
||||
|
||||
func TestDependencies(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
// NaCl tests run in a limited file system and we do not
|
||||
// provide access to every source file.
|
||||
t.Skip("skipping on NaCl")
|
||||
}
|
||||
var all []string
|
||||
|
||||
for k := range pkgDeps {
|
||||
|
|
@ -387,6 +393,9 @@ func TestDependencies(t *testing.T) {
|
|||
if isMacro(pkg) {
|
||||
continue
|
||||
}
|
||||
if pkg == "runtime/cgo" && !ctxt.CgoEnabled {
|
||||
continue
|
||||
}
|
||||
p, err := ctxt.Import(pkg, "", 0)
|
||||
if err != nil {
|
||||
if allowedErrors[osPkg{ctxt.GOOS, pkg}] {
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
package build
|
||||
|
||||
const goosList = "darwin dragonfly freebsd linux netbsd openbsd plan9 solaris windows "
|
||||
const goarchList = "386 amd64 arm "
|
||||
const goosList = "darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows "
|
||||
const goarchList = "386 amd64 amd64p32 arm "
|
||||
|
|
|
|||
64
src/pkg/hash/crc32/crc32_amd64p32.s
Normal file
64
src/pkg/hash/crc32/crc32_amd64p32.s
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
// Copyright 2011 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 "../../../cmd/ld/textflag.h"
|
||||
|
||||
// func castagnoliSSE42(crc uint32, p []byte) uint32
|
||||
TEXT ·castagnoliSSE42(SB),NOSPLIT,$0
|
||||
MOVL crc+0(FP), AX // CRC value
|
||||
MOVL p+4(FP), SI // data pointer
|
||||
MOVL p_len+8(FP), CX // len(p)
|
||||
|
||||
NOTL AX
|
||||
|
||||
/* If there's less than 8 bytes to process, we do it byte-by-byte. */
|
||||
CMPQ CX, $8
|
||||
JL cleanup
|
||||
|
||||
/* Process individual bytes until the input is 8-byte aligned. */
|
||||
startup:
|
||||
MOVQ SI, BX
|
||||
ANDQ $7, BX
|
||||
JZ aligned
|
||||
|
||||
CRC32B (SI), AX
|
||||
DECQ CX
|
||||
INCQ SI
|
||||
JMP startup
|
||||
|
||||
aligned:
|
||||
/* The input is now 8-byte aligned and we can process 8-byte chunks. */
|
||||
CMPQ CX, $8
|
||||
JL cleanup
|
||||
|
||||
CRC32Q (SI), AX
|
||||
ADDQ $8, SI
|
||||
SUBQ $8, CX
|
||||
JMP aligned
|
||||
|
||||
cleanup:
|
||||
/* We may have some bytes left over that we process one at a time. */
|
||||
CMPQ CX, $0
|
||||
JE done
|
||||
|
||||
CRC32B (SI), AX
|
||||
INCQ SI
|
||||
DECQ CX
|
||||
JMP cleanup
|
||||
|
||||
done:
|
||||
NOTL AX
|
||||
MOVL AX, ret+16(FP)
|
||||
RET
|
||||
|
||||
// func haveSSE42() bool
|
||||
TEXT ·haveSSE42(SB),NOSPLIT,$0
|
||||
XORQ AX, AX
|
||||
INCL AX
|
||||
CPUID
|
||||
SHRQ $20, CX
|
||||
ANDQ $1, CX
|
||||
MOVB CX, ret+0(FP)
|
||||
RET
|
||||
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build amd64 amd64p32
|
||||
|
||||
package crc32
|
||||
|
||||
// This file contains the code to call the SSE 4.2 version of the Castagnoli
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !windows,!plan9
|
||||
// +build !windows,!nacl,!plan9
|
||||
|
||||
// Package syslog provides a simple interface to the system log
|
||||
// service. It can send messages to the syslog daemon using UNIX
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !windows,!plan9
|
||||
// +build !windows,!nacl,!plan9
|
||||
|
||||
package syslog
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !windows,!plan9
|
||||
// +build !windows,!nacl,!plan9
|
||||
|
||||
package syslog
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package mime
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func TestConnAndListener(t *testing.T) {
|
|||
switch tt.net {
|
||||
case "unix", "unixpacket":
|
||||
switch runtime.GOOS {
|
||||
case "plan9", "windows":
|
||||
case "plan9", "windows", "nacl":
|
||||
continue
|
||||
}
|
||||
if tt.net == "unixpacket" && runtime.GOOS != "linux" {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
// DNS client: see RFC 1035.
|
||||
// Has to be linked into package net for Dial.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
// Read system DNS config from /etc/resolv.conf
|
||||
|
||||
|
|
|
|||
94
src/pkg/net/fd_poll_nacl.go
Normal file
94
src/pkg/net/fd_poll_nacl.go
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
// Copyright 2013 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.
|
||||
|
||||
package net
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
type pollDesc struct {
|
||||
fd *netFD
|
||||
closing bool
|
||||
}
|
||||
|
||||
func (pd *pollDesc) Init(fd *netFD) error { pd.fd = fd; return nil }
|
||||
|
||||
func (pd *pollDesc) Close() {}
|
||||
|
||||
func (pd *pollDesc) Lock() {}
|
||||
|
||||
func (pd *pollDesc) Unlock() {}
|
||||
|
||||
func (pd *pollDesc) Wakeup() {}
|
||||
|
||||
func (pd *pollDesc) Evict() bool {
|
||||
pd.closing = true
|
||||
if pd.fd != nil {
|
||||
syscall.StopIO(pd.fd.sysfd)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (pd *pollDesc) Prepare(mode int) error {
|
||||
if pd.closing {
|
||||
return errClosing
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pd *pollDesc) PrepareRead() error { return pd.Prepare('r') }
|
||||
|
||||
func (pd *pollDesc) PrepareWrite() error { return pd.Prepare('w') }
|
||||
|
||||
func (pd *pollDesc) Wait(mode int) error {
|
||||
if pd.closing {
|
||||
return errClosing
|
||||
}
|
||||
return errTimeout
|
||||
}
|
||||
|
||||
func (pd *pollDesc) WaitRead() error { return pd.Wait('r') }
|
||||
|
||||
func (pd *pollDesc) WaitWrite() error { return pd.Wait('w') }
|
||||
|
||||
func (pd *pollDesc) WaitCanceled(mode int) {}
|
||||
|
||||
func (pd *pollDesc) WaitCanceledRead() {}
|
||||
|
||||
func (pd *pollDesc) WaitCanceledWrite() {}
|
||||
|
||||
func (fd *netFD) setDeadline(t time.Time) error {
|
||||
return setDeadlineImpl(fd, t, 'r'+'w')
|
||||
}
|
||||
|
||||
func (fd *netFD) setReadDeadline(t time.Time) error {
|
||||
return setDeadlineImpl(fd, t, 'r')
|
||||
}
|
||||
|
||||
func (fd *netFD) setWriteDeadline(t time.Time) error {
|
||||
return setDeadlineImpl(fd, t, 'w')
|
||||
}
|
||||
|
||||
func setDeadlineImpl(fd *netFD, t time.Time, mode int) error {
|
||||
d := t.UnixNano()
|
||||
if t.IsZero() {
|
||||
d = 0
|
||||
}
|
||||
if err := fd.incref(); err != nil {
|
||||
return err
|
||||
}
|
||||
switch mode {
|
||||
case 'r':
|
||||
syscall.SetReadDeadline(fd.sysfd, d)
|
||||
case 'w':
|
||||
syscall.SetWriteDeadline(fd.sysfd, d)
|
||||
case 'r' + 'w':
|
||||
syscall.SetReadDeadline(fd.sysfd, d)
|
||||
syscall.SetWriteDeadline(fd.sysfd, d)
|
||||
}
|
||||
fd.decref()
|
||||
return nil
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ var filePacketConnTests = []struct {
|
|||
|
||||
func TestFilePacketConn(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "plan9", "windows":
|
||||
case "plan9", "windows", "nacl":
|
||||
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package net
|
||||
|
||||
|
|
@ -24,6 +24,7 @@ func newFileFD(f *os.File) (*netFD, error) {
|
|||
|
||||
sotype, err := syscall.GetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_TYPE)
|
||||
if err != nil {
|
||||
println("getsockopt failed", fd, err.Error())
|
||||
closesocket(fd)
|
||||
return nil, os.NewSyscallError("getsockopt", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build plan9 solaris
|
||||
// +build nacl plan9 solaris
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ var ipConnLocalNameTests = []struct {
|
|||
|
||||
func TestIPConnLocalName(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "plan9", "windows":
|
||||
case "plan9", "windows", "nacl":
|
||||
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||
default:
|
||||
if os.Getuid() != 0 {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
// Internet protocol family sockets for POSIX
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ var ipv4MulticastListenerTests = []struct {
|
|||
// port.
|
||||
func TestIPv4MulticastListener(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "plan9":
|
||||
case "nacl", "plan9":
|
||||
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||
case "solaris":
|
||||
t.Skipf("skipping test on solaris, see issue 7399")
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func TestShutdown(t *testing.T) {
|
|||
|
||||
func TestShutdownUnix(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "windows", "plan9":
|
||||
case "nacl", "plan9", "windows":
|
||||
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||
}
|
||||
f, err := ioutil.TempFile("", "go_net_unixtest")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
// Read system port mappings from /etc/services
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin netbsd openbsd solaris
|
||||
// +build darwin nacl netbsd openbsd solaris
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
// +build darwin dragonfly freebsd nacl netbsd openbsd
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
// +build darwin dragonfly freebsd nacl netbsd openbsd
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd nacl netbsd openbsd solaris
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// This file implements sysSocket and accept for platforms that do not
|
||||
// provide a fast path for setting SetNonblock and CloseOnExec.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd nacl netbsd openbsd solaris
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build dragonfly freebsd linux netbsd
|
||||
// +build dragonfly freebsd linux nacl netbsd
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package os
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package os
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package exec
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package os
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package os
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package os
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package os
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package os
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd nacl netbsd openbsd solaris
|
||||
|
||||
package os
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Assembly to get into package runtime without using exported symbols.
|
||||
|
||||
// +build amd64 arm 386
|
||||
// +build amd64 amd64p32 arm 386
|
||||
|
||||
#include "../../../cmd/ld/textflag.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package signal
|
||||
|
||||
|
|
|
|||
62
src/pkg/os/stat_nacl.go
Normal file
62
src/pkg/os/stat_nacl.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// 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.
|
||||
|
||||
package os
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
func sameFile(fs1, fs2 *fileStat) bool {
|
||||
stat1 := fs1.sys.(*syscall.Stat_t)
|
||||
stat2 := fs2.sys.(*syscall.Stat_t)
|
||||
return stat1.Dev == stat2.Dev && stat1.Ino == stat2.Ino
|
||||
}
|
||||
|
||||
func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo {
|
||||
fs := &fileStat{
|
||||
name: basename(name),
|
||||
size: int64(st.Size),
|
||||
modTime: timespecToTime(st.Mtime, st.MtimeNsec),
|
||||
sys: st,
|
||||
}
|
||||
fs.mode = FileMode(st.Mode & 0777)
|
||||
switch st.Mode & syscall.S_IFMT {
|
||||
case syscall.S_IFBLK:
|
||||
fs.mode |= ModeDevice
|
||||
case syscall.S_IFCHR:
|
||||
fs.mode |= ModeDevice | ModeCharDevice
|
||||
case syscall.S_IFDIR:
|
||||
fs.mode |= ModeDir
|
||||
case syscall.S_IFIFO:
|
||||
fs.mode |= ModeNamedPipe
|
||||
case syscall.S_IFLNK:
|
||||
fs.mode |= ModeSymlink
|
||||
case syscall.S_IFREG:
|
||||
// nothing to do
|
||||
case syscall.S_IFSOCK:
|
||||
fs.mode |= ModeSocket
|
||||
}
|
||||
if st.Mode&syscall.S_ISGID != 0 {
|
||||
fs.mode |= ModeSetgid
|
||||
}
|
||||
if st.Mode&syscall.S_ISUID != 0 {
|
||||
fs.mode |= ModeSetuid
|
||||
}
|
||||
if st.Mode&syscall.S_ISVTX != 0 {
|
||||
fs.mode |= ModeSticky
|
||||
}
|
||||
return fs
|
||||
}
|
||||
|
||||
func timespecToTime(sec, nsec int64) time.Time {
|
||||
return time.Unix(sec, nsec)
|
||||
}
|
||||
|
||||
// For testing.
|
||||
func atime(fi FileInfo) time.Time {
|
||||
st := fi.Sys().(*syscall.Stat_t)
|
||||
return timespecToTime(st.Atime, st.AtimeNsec)
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
// +build darwin dragonfly freebsd nacl netbsd openbsd
|
||||
|
||||
// os code shared between *BSD systems including OS X (Darwin)
|
||||
// and FreeBSD.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package filepath
|
||||
|
||||
|
|
|
|||
27
src/pkg/reflect/asm_amd64p32.s
Normal file
27
src/pkg/reflect/asm_amd64p32.s
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2012 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 "../../cmd/ld/textflag.h"
|
||||
|
||||
// makeFuncStub is the code half of the function returned by MakeFunc.
|
||||
// See the comment on the declaration of makeFuncStub in makefunc.go
|
||||
// for more details.
|
||||
// No argsize here, gc generates argsize info at call site.
|
||||
TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$8
|
||||
MOVL DX, 0(SP)
|
||||
LEAL argframe+0(FP), CX
|
||||
MOVL CX, 4(SP)
|
||||
CALL ·callReflect(SB)
|
||||
RET
|
||||
|
||||
// methodValueCall is the code half of the function returned by makeMethodValue.
|
||||
// See the comment on the declaration of methodValueCall in makefunc.go
|
||||
// for more details.
|
||||
// No argsize here, gc generates argsize info at call site.
|
||||
TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$8
|
||||
MOVL DX, 0(SP)
|
||||
LEAL argframe+0(FP), CX
|
||||
MOVL CX, 4(SP)
|
||||
CALL ·callMethod(SB)
|
||||
RET
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
package reflect
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
|
@ -1572,6 +1573,10 @@ func bucketOf(ktyp, etyp *rtype) *rtype {
|
|||
gc = append(gc, _GC_PTR, offset, 0 /*self pointer set below*/) // overflow
|
||||
offset += ptrsize
|
||||
|
||||
if runtime.GOARCH == "amd64p32" {
|
||||
offset += 4
|
||||
}
|
||||
|
||||
// keys
|
||||
if ktyp.kind&kindNoPointers == 0 {
|
||||
gc = append(gc, _GC_ARRAY_START, offset, _BUCKETSIZE, ktyp.size)
|
||||
|
|
|
|||
|
|
@ -7,5 +7,10 @@ enum {
|
|||
BigEndian = 0,
|
||||
CacheLineSize = 64,
|
||||
RuntimeGogoBytes = 64,
|
||||
#ifdef GOOS_nacl
|
||||
PhysPageSize = 65536,
|
||||
#else
|
||||
PhysPageSize = 4096,
|
||||
#endif
|
||||
PCQuantum = 1
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ enum {
|
|||
RuntimeGogoBytes = 80,
|
||||
#else
|
||||
RuntimeGogoBytes = 64,
|
||||
#endif
|
||||
#ifdef GOOS_nacl
|
||||
PhysPageSize = 65536,
|
||||
#else
|
||||
PhysPageSize = 4096,
|
||||
#endif
|
||||
PCQuantum = 1
|
||||
};
|
||||
|
|
|
|||
20
src/pkg/runtime/arch_amd64p32.h
Normal file
20
src/pkg/runtime/arch_amd64p32.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2011 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.
|
||||
|
||||
enum {
|
||||
thechar = '6',
|
||||
BigEndian = 0,
|
||||
CacheLineSize = 64,
|
||||
#ifdef GOOS_solaris
|
||||
RuntimeGogoBytes = 80,
|
||||
#else
|
||||
RuntimeGogoBytes = 64,
|
||||
#endif
|
||||
#ifdef GOOS_nacl
|
||||
PhysPageSize = 65536,
|
||||
#else
|
||||
PhysPageSize = 4096,
|
||||
#endif
|
||||
PCQuantum = 1
|
||||
};
|
||||
|
|
@ -7,5 +7,6 @@ enum {
|
|||
BigEndian = 0,
|
||||
CacheLineSize = 32,
|
||||
RuntimeGogoBytes = 80,
|
||||
PhysPageSize = 4096,
|
||||
PCQuantum = 4
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
enum
|
||||
{
|
||||
_PAGE_SIZE = 4096,
|
||||
EACCES = 13,
|
||||
};
|
||||
|
||||
static int32
|
||||
|
|
|
|||
109
src/pkg/runtime/mem_nacl.c
Normal file
109
src/pkg/runtime/mem_nacl.c
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
// Copyright 2010 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 "runtime.h"
|
||||
#include "arch_GOARCH.h"
|
||||
#include "defs_GOOS_GOARCH.h"
|
||||
#include "os_GOOS.h"
|
||||
#include "malloc.h"
|
||||
|
||||
enum
|
||||
{
|
||||
Debug = 0,
|
||||
};
|
||||
|
||||
void*
|
||||
runtime·SysAlloc(uintptr n, uint64 *stat)
|
||||
{
|
||||
void *v;
|
||||
|
||||
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
||||
if(v < (void*)4096) {
|
||||
if(Debug)
|
||||
runtime·printf("SysAlloc(%p): %p\n", n, v);
|
||||
return nil;
|
||||
}
|
||||
runtime·xadd64(stat, n);
|
||||
if(Debug)
|
||||
runtime·printf("SysAlloc(%p) = %p\n", n, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
void
|
||||
runtime·SysUnused(void *v, uintptr n)
|
||||
{
|
||||
if(Debug)
|
||||
runtime·printf("SysUnused(%p, %p)\n", v, n);
|
||||
}
|
||||
|
||||
void
|
||||
runtime·SysUsed(void *v, uintptr n)
|
||||
{
|
||||
USED(v);
|
||||
USED(n);
|
||||
}
|
||||
|
||||
void
|
||||
runtime·SysFree(void *v, uintptr n, uint64 *stat)
|
||||
{
|
||||
if(Debug)
|
||||
runtime·printf("SysFree(%p, %p)\n", v, n);
|
||||
runtime·xadd64(stat, -(uint64)n);
|
||||
runtime·munmap(v, n);
|
||||
}
|
||||
|
||||
void*
|
||||
runtime·SysReserve(void *v, uintptr n)
|
||||
{
|
||||
void *p;
|
||||
|
||||
// On 64-bit, people with ulimit -v set complain if we reserve too
|
||||
// much address space. Instead, assume that the reservation is okay
|
||||
// and check the assumption in SysMap.
|
||||
if(NaCl || sizeof(void*) == 8)
|
||||
return v;
|
||||
|
||||
p = runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
||||
if(p < (void*)4096)
|
||||
return nil;
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
runtime·SysMap(void *v, uintptr n, uint64 *stat)
|
||||
{
|
||||
void *p;
|
||||
|
||||
runtime·xadd64(stat, n);
|
||||
|
||||
// On 64-bit, we don't actually have v reserved, so tread carefully.
|
||||
if(sizeof(void*) == 8) {
|
||||
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
||||
if(p == (void*)ENOMEM) {
|
||||
runtime·printf("SysMap(%p, %p): %p\n", v, n, p);
|
||||
runtime·throw("runtime: out of memory");
|
||||
}
|
||||
if(p != v) {
|
||||
runtime·printf("SysMap(%p, %p): %p\n", v, n, p);
|
||||
runtime·printf("runtime: address space conflict: map(%p) = %p\n", v, p);
|
||||
runtime·throw("runtime: address space conflict");
|
||||
}
|
||||
if(Debug)
|
||||
runtime·printf("SysMap(%p, %p) = %p\n", v, n, p);
|
||||
return;
|
||||
}
|
||||
|
||||
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
|
||||
if(p == (void*)ENOMEM) {
|
||||
runtime·printf("SysMap(%p, %p): %p\n", v, n, p);
|
||||
runtime·throw("runtime: out of memory");
|
||||
}
|
||||
if(p != v) {
|
||||
runtime·printf("SysMap(%p, %p): %p\n", v, n, p);
|
||||
runtime·printf("mmap MAP_FIXED %p returned %p\n", v, p);
|
||||
runtime·throw("runtime: cannot map pages in arena address space");
|
||||
}
|
||||
if(Debug)
|
||||
runtime·printf("SysMap(%p, %p) = %p\n", v, n, p);
|
||||
}
|
||||
|
|
@ -2771,6 +2771,7 @@ runtime·MHeap_MapBits(MHeap *h)
|
|||
|
||||
n = (h->arena_used - h->arena_start) / wordsPerBitmapWord;
|
||||
n = ROUND(n, bitmapChunk);
|
||||
n = ROUND(n, PhysPageSize);
|
||||
if(h->bitmap_mapped >= n)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ runtime·MHeap_MapSpans(MHeap *h)
|
|||
n = (uintptr)h->arena_used;
|
||||
n -= (uintptr)h->arena_start;
|
||||
n = n / PageSize * sizeof(h->spans[0]);
|
||||
n = ROUND(n, PageSize);
|
||||
n = ROUND(n, PhysPageSize);
|
||||
if(h->spans_mapped >= n)
|
||||
return;
|
||||
runtime·SysMap((byte*)h->spans + h->spans_mapped, n - h->spans_mapped, &mstats.other_sys);
|
||||
|
|
|
|||
15
src/pkg/runtime/mknacl.sh
Normal file
15
src/pkg/runtime/mknacl.sh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2013 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.
|
||||
|
||||
cat /Users/rsc/pub/native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h |
|
||||
awk '
|
||||
BEGIN {
|
||||
printf("// generated by mknacl.sh - do not edit\n")
|
||||
}
|
||||
NF==3 && $1=="#define" && $2~/^NACL_sys_/ {
|
||||
name=$2
|
||||
sub(/^NACL_sys_/, "SYS_", name)
|
||||
printf("#define %s %s\n", name, $3)
|
||||
}' >syscall_nacl.h
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
||||
|
||||
package net
|
||||
|
||||
|
|
|
|||
37
src/pkg/runtime/netpoll_nacl.c
Normal file
37
src/pkg/runtime/netpoll_nacl.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2013 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 "runtime.h"
|
||||
#include "defs_GOOS_GOARCH.h"
|
||||
#include "os_GOOS.h"
|
||||
|
||||
// Fake network poller for NaCl.
|
||||
// Should never be used, because NaCl network connections do not honor "SetNonblock".
|
||||
|
||||
void
|
||||
runtime·netpollinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
int32
|
||||
runtime·netpollopen(uintptr fd, PollDesc *pd)
|
||||
{
|
||||
USED(fd);
|
||||
USED(pd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32
|
||||
runtime·netpollclose(uintptr fd)
|
||||
{
|
||||
USED(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
G*
|
||||
runtime·netpoll(bool block)
|
||||
{
|
||||
USED(block);
|
||||
return nil;
|
||||
}
|
||||
275
src/pkg/runtime/os_nacl.c
Normal file
275
src/pkg/runtime/os_nacl.c
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
// Copyright 2010 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 "runtime.h"
|
||||
#include "defs_GOOS_GOARCH.h"
|
||||
#include "os_GOOS.h"
|
||||
#include "arch_GOARCH.h"
|
||||
#include "../../cmd/ld/textflag.h"
|
||||
#include "stack.h"
|
||||
|
||||
int8 *goos = "nacl";
|
||||
extern SigTab runtime·sigtab[];
|
||||
|
||||
void runtime·sigtramp(void);
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
||||
void
|
||||
runtime·mpreinit(M *mp)
|
||||
{
|
||||
mp->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the new thread, can not allocate memory.
|
||||
void
|
||||
runtime·minit(void)
|
||||
{
|
||||
int32 ret;
|
||||
|
||||
// Initialize signal handling
|
||||
ret = runtime·nacl_exception_stack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
|
||||
if(ret < 0)
|
||||
runtime·printf("runtime: nacl_exception_stack: error %d\n", -ret);
|
||||
|
||||
ret = runtime·nacl_exception_handler(runtime·sigtramp, nil);
|
||||
if(ret < 0)
|
||||
runtime·printf("runtime: nacl_exception_handler: error %d\n", -ret);
|
||||
}
|
||||
|
||||
// Called from dropm to undo the effect of an minit.
|
||||
void
|
||||
runtime·unminit(void)
|
||||
{
|
||||
}
|
||||
|
||||
int8 runtime·sigtrampf[] = "runtime: signal at PC=%X AX=%X CX=%X DX=%X BX=%X DI=%X R15=%X *SP=%X\n";
|
||||
int8 runtime·sigtrampp[] = "runtime: sigtramp";
|
||||
|
||||
extern byte runtime·tls0[];
|
||||
|
||||
void
|
||||
runtime·osinit(void)
|
||||
{
|
||||
runtime·ncpu = 1;
|
||||
m->procid = 2;
|
||||
//runtime·nacl_exception_handler(runtime·sigtramp, nil);
|
||||
}
|
||||
|
||||
void
|
||||
runtime·crash(void)
|
||||
{
|
||||
*(int32*)0 = 0;
|
||||
}
|
||||
|
||||
void
|
||||
runtime·get_random_data(byte **rnd, int32 *rnd_len)
|
||||
{
|
||||
*rnd = nil;
|
||||
*rnd_len = 0;
|
||||
}
|
||||
|
||||
void
|
||||
runtime·goenvs(void)
|
||||
{
|
||||
runtime·goenvs_unix();
|
||||
}
|
||||
|
||||
void
|
||||
runtime·initsig(void)
|
||||
{
|
||||
}
|
||||
|
||||
#pragma textflag NOSPLIT
|
||||
void
|
||||
runtime·usleep(uint32 us)
|
||||
{
|
||||
Timespec ts;
|
||||
|
||||
ts.tv_sec = us/1000000;
|
||||
ts.tv_nsec = (us%1000000)*1000;
|
||||
runtime·nacl_nanosleep(&ts, nil);
|
||||
}
|
||||
|
||||
void runtime·mstart_nacl(void);
|
||||
|
||||
void
|
||||
runtime·newosproc(M *mp, void *stk)
|
||||
{
|
||||
int32 ret;
|
||||
void **tls;
|
||||
|
||||
tls = (void**)mp->tls;
|
||||
tls[0] = mp->g0;
|
||||
tls[1] = mp;
|
||||
ret = runtime·nacl_thread_create(runtime·mstart_nacl, stk, tls+2, 0);
|
||||
if(ret < 0) {
|
||||
runtime·printf("nacl_thread_create: error %d\n", -ret);
|
||||
runtime·throw("newosproc");
|
||||
}
|
||||
}
|
||||
|
||||
uintptr
|
||||
runtime·semacreate(void)
|
||||
{
|
||||
int32 mu, cond;
|
||||
|
||||
mu = runtime·nacl_mutex_create(0);
|
||||
if(mu < 0) {
|
||||
runtime·printf("nacl_mutex_create: error %d\n", -mu);
|
||||
runtime·throw("semacreate");
|
||||
}
|
||||
cond = runtime·nacl_cond_create(0);
|
||||
if(cond < 0) {
|
||||
runtime·printf("nacl_cond_create: error %d\n", -cond);
|
||||
runtime·throw("semacreate");
|
||||
}
|
||||
m->waitsemalock = mu;
|
||||
return cond; // assigned to m->waitsema
|
||||
}
|
||||
|
||||
#pragma textflag NOSPLIT
|
||||
int32
|
||||
runtime·semasleep(int64 ns)
|
||||
{
|
||||
int32 ret;
|
||||
|
||||
ret = runtime·nacl_mutex_lock(m->waitsemalock);
|
||||
if(ret < 0) {
|
||||
//runtime·printf("nacl_mutex_lock: error %d\n", -ret);
|
||||
runtime·throw("semasleep");
|
||||
}
|
||||
if(m->waitsemacount > 0) {
|
||||
m->waitsemacount = 0;
|
||||
runtime·nacl_mutex_unlock(m->waitsemalock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while(m->waitsemacount == 0) {
|
||||
if(ns < 0) {
|
||||
ret = runtime·nacl_cond_wait(m->waitsema, m->waitsemalock);
|
||||
if(ret < 0) {
|
||||
//runtime·printf("nacl_cond_wait: error %d\n", -ret);
|
||||
runtime·throw("semasleep");
|
||||
}
|
||||
} else {
|
||||
Timespec ts;
|
||||
|
||||
ns += runtime·nanotime();
|
||||
ts.tv_sec = runtime·timediv(ns, 1000000000, (int32*)&ts.tv_nsec);
|
||||
ret = runtime·nacl_cond_timed_wait_abs(m->waitsema, m->waitsemalock, &ts);
|
||||
if(ret == -ETIMEDOUT) {
|
||||
runtime·nacl_mutex_unlock(m->waitsemalock);
|
||||
return -1;
|
||||
}
|
||||
if(ret < 0) {
|
||||
//runtime·printf("nacl_cond_timed_wait_abs: error %d\n", -ret);
|
||||
runtime·throw("semasleep");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m->waitsemacount = 0;
|
||||
runtime·nacl_mutex_unlock(m->waitsemalock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
runtime·semawakeup(M *mp)
|
||||
{
|
||||
int32 ret;
|
||||
|
||||
ret = runtime·nacl_mutex_lock(mp->waitsemalock);
|
||||
if(ret < 0) {
|
||||
//runtime·printf("nacl_mutex_lock: error %d\n", -ret);
|
||||
runtime·throw("semawakeup");
|
||||
}
|
||||
if(mp->waitsemacount != 0) {
|
||||
//runtime·printf("semawakeup: double wakeup\n");
|
||||
runtime·throw("semawakeup");
|
||||
}
|
||||
mp->waitsemacount = 1;
|
||||
runtime·nacl_cond_signal(mp->waitsema);
|
||||
runtime·nacl_mutex_unlock(mp->waitsemalock);
|
||||
}
|
||||
|
||||
void
|
||||
os·sigpipe(void)
|
||||
{
|
||||
runtime·throw("too many writes on closed pipe");
|
||||
}
|
||||
|
||||
uintptr
|
||||
runtime·memlimit(void)
|
||||
{
|
||||
runtime·printf("memlimit\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma dataflag NOPTR
|
||||
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
||||
|
||||
// This runs on a foreign stack, without an m or a g. No stack split.
|
||||
#pragma textflag NOSPLIT
|
||||
void
|
||||
runtime·badsignal2(void)
|
||||
{
|
||||
runtime·write(2, badsignal, sizeof badsignal - 1);
|
||||
runtime·exit(2);
|
||||
}
|
||||
|
||||
void runtime·madvise(byte*, uintptr, int32) { }
|
||||
void runtime·munmap(byte*, uintptr) {}
|
||||
|
||||
void
|
||||
runtime·resetcpuprofiler(int32 hz)
|
||||
{
|
||||
USED(hz);
|
||||
}
|
||||
|
||||
void
|
||||
runtime·sigdisable(uint32)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
runtime·sigenable(uint32)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
runtime·closeonexec(int32)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
// Native Client only invokes the exception handler for memory faults.
|
||||
g->sig = SIGSEGV;
|
||||
if(g->sigpc == 0)
|
||||
runtime·panicstring("call of nil func value");
|
||||
runtime·panicstring("invalid memory address or nil pointer dereference");
|
||||
}
|
||||
|
||||
uint32 runtime·writelock; // test-and-set spin lock for runtime.write
|
||||
|
||||
/*
|
||||
An attempt at IRT. Doesn't work. See end of sys_nacl_amd64.s.
|
||||
|
||||
void (*runtime·nacl_irt_query)(void);
|
||||
|
||||
int8 runtime·nacl_irt_basic_v0_1_str[] = "nacl-irt-basic-0.1";
|
||||
void *runtime·nacl_irt_basic_v0_1[6]; // exit, gettod, clock, nanosleep, sched_yield, sysconf
|
||||
int32 runtime·nacl_irt_basic_v0_1_size = sizeof(runtime·nacl_irt_basic_v0_1);
|
||||
|
||||
int8 runtime·nacl_irt_memory_v0_3_str[] = "nacl-irt-memory-0.3";
|
||||
void *runtime·nacl_irt_memory_v0_3[3]; // mmap, munmap, mprotect
|
||||
int32 runtime·nacl_irt_memory_v0_3_size = sizeof(runtime·nacl_irt_memory_v0_3);
|
||||
|
||||
int8 runtime·nacl_irt_thread_v0_1_str[] = "nacl-irt-thread-0.1";
|
||||
void *runtime·nacl_irt_thread_v0_1[3]; // thread_create, thread_exit, thread_nice
|
||||
int32 runtime·nacl_irt_thread_v0_1_size = sizeof(runtime·nacl_irt_thread_v0_1);
|
||||
*/
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue