R=golang-dev, dsymonds, minux.ma, iant, alex.brainman
CC=golang-dev
https://golang.org/cl/
7035055
void bgrunv(char *dir, int mode, Vec *argv);
void bgwait(void);
bool streq(char*, char*);
+bool cansse(void);
void writefile(Buf*, char*, int);
void xatexit(void (*f)(void));
void xexit(int);
goarm = btake(&b);
xgetenv(&b, "GO386");
- if(b.len == 0)
- bwritestr(&b, "387");
+ if(b.len == 0) {
+ if(cansse())
+ bwritestr(&b, "sse");
+ else
+ bwritestr(&b, "387");
+ }
go386 = btake(&b);
p = bpathf(&b, "%s/include/u.h", goroot);
return 0; // suffice for now
}
+bool
+cansse(void)
+{
+ // if we had access to cpuid, could answer this question
+ // less conservatively.
+ return 0;
+}
+
#endif // PLAN9
sigjmp_buf sigill_jmpbuf;
static void sigillhand(int);
+
// xtryexecfunc tries to execute function f, if any illegal instruction
// signal received in the course of executing that function, it will
// return 0, otherwise it will return 1.
signal(SIGILL, SIG_DFL);
return r;
}
+
// SIGILL handler helper
static void
sigillhand(int signum)
siglongjmp(sigill_jmpbuf, 1);
}
+static void
+__cpuid(int dst[4], int ax)
+{
+#if defined(__i386__) || defined(__x86_64__)
+ asm volatile("cpuid"
+ : "=a" (dst[0]), "=b" (dst[1]), "=c" (dst[2]), "=d" (dst[3])
+ : "0" (ax));
+#else
+ dst[0] = dst[1] = dst[2] = dst[3] = 0;
+#endif
+}
+
+bool
+cansse(void)
+{
+ int info[4];
+
+ __cpuid(info, 1);
+ return (info[3] & (1<<26)) != 0; // SSE2
+}
+
#endif // PLAN9
#endif // __WINDOWS__
return 0; // suffice for now
}
+static void
+cpuid(int dst[4], int ax)
+{
+ // NOTE: This asm statement is for mingw.
+ // If we ever support MSVC, use __cpuid(dst, ax)
+ // to use the built-in.
+#if defined(__i386__) || defined(__x86_64__)
+ asm volatile("cpuid"
+ : "=a" (dst[0]), "=b" (dst[1]), "=c" (dst[2]), "=d" (dst[3])
+ : "0" (ax));
+#else
+ dst[0] = dst[1] = dst[2] = dst[3] = 0;
+#endif
+}
+
+bool
+cansse(void)
+{
+ int info[4];
+
+ cpuid(info, 1);
+ return (info[3] & (1<<26)) != 0; // SSE2
+}
+
+
#endif // __WINDOWS__