summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2012-12-23 15:11:11 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2012-12-23 15:11:11 +0000
commite4c6008c17e1f0f41b51ab3a011dd242b510e75a (patch)
treeeda046151efb68fbe0919dc570e7194d02868aef
parentd8e2e51e26185390022dbfa65ceacd9f35290693 (diff)
Regression test for proper stack alignment for SSE2 instructions.
-rw-r--r--regress/misc/sse2/Makefile5
-rw-r--r--regress/misc/sse2/foo/Makefile16
-rw-r--r--regress/misc/sse2/foo/foo.c29
-rw-r--r--regress/misc/sse2/libbar/Makefile8
-rw-r--r--regress/misc/sse2/libbar/bar.c12
-rw-r--r--regress/misc/sse2/libbar/shlib_version2
6 files changed, 72 insertions, 0 deletions
diff --git a/regress/misc/sse2/Makefile b/regress/misc/sse2/Makefile
new file mode 100644
index 00000000000..be58f147fc3
--- /dev/null
+++ b/regress/misc/sse2/Makefile
@@ -0,0 +1,5 @@
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
+SUBDIR+= libbar foo
+.endif
+
+.include <bsd.subdir.mk>
diff --git a/regress/misc/sse2/foo/Makefile b/regress/misc/sse2/foo/Makefile
new file mode 100644
index 00000000000..fc5bb84bf81
--- /dev/null
+++ b/regress/misc/sse2/foo/Makefile
@@ -0,0 +1,16 @@
+.include <bsd.obj.mk>
+
+BAR_DIR= ${.CURDIR}/../libbar
+
+BAR_OBJDIR!= if [ -d $(BAR_DIR)/${__objdir} ]; then \
+ echo "$(BAR_DIR)/${__objdir}"; \
+ else \
+ echo "$(BAR_DIR)"; \
+ fi
+
+PROG= foo
+SRCS= foo.c
+LDADD= -Wl,-rpath,$(BAR_OBJDIR) -L$(BAR_OBJDIR) -lbar -lpthread
+CFLAGS+= -msse2
+
+.include <bsd.regress.mk>
diff --git a/regress/misc/sse2/foo/foo.c b/regress/misc/sse2/foo/foo.c
new file mode 100644
index 00000000000..bc95372e0c6
--- /dev/null
+++ b/regress/misc/sse2/foo/foo.c
@@ -0,0 +1,29 @@
+#include <emmintrin.h>
+#include <pthread.h>
+
+void foobar(void) __attribute__((constructor));
+
+void *
+foo(void *arg)
+{
+ __m128i xmm_alpha;
+
+ if ((((unsigned long)&xmm_alpha) & 15) != 0)
+ exit(1);
+}
+
+void
+foobar(void)
+{
+ foo(NULL);
+}
+
+int
+main(void)
+{
+ pthread_t thread;
+
+ foo(NULL);
+ pthread_create(&thread, NULL, foo, NULL);
+ return 0;
+}
diff --git a/regress/misc/sse2/libbar/Makefile b/regress/misc/sse2/libbar/Makefile
new file mode 100644
index 00000000000..a5ce621d0f7
--- /dev/null
+++ b/regress/misc/sse2/libbar/Makefile
@@ -0,0 +1,8 @@
+LIB= bar
+SRCS= bar.c
+
+CFLAGS+= -msse2
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/misc/sse2/libbar/bar.c b/regress/misc/sse2/libbar/bar.c
new file mode 100644
index 00000000000..2d47a8209fe
--- /dev/null
+++ b/regress/misc/sse2/libbar/bar.c
@@ -0,0 +1,12 @@
+#include <emmintrin.h>
+
+void bar(void) __attribute__((constructor));
+
+void
+bar(void)
+{
+ __m128i xmm_alpha;
+
+ if ((((unsigned long)&xmm_alpha) & 15) != 0)
+ exit(1);
+}
diff --git a/regress/misc/sse2/libbar/shlib_version b/regress/misc/sse2/libbar/shlib_version
new file mode 100644
index 00000000000..1edea46de91
--- /dev/null
+++ b/regress/misc/sse2/libbar/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0