summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2005-04-26 21:37:00 +0000
committermiod <miod@openbsd.org>2005-04-26 21:37:00 +0000
commit15b2b61eba295e188dc834d5cb63fc21adb82d9a (patch)
tree035ae0ef60ab5c4f74253d3ffc99dbc8d8fe2037
parentremove now obsolete mac68k_set_pte (diff)
downloadwireguard-openbsd-15b2b61eba295e188dc834d5cb63fc21adb82d9a.tar.xz
wireguard-openbsd-15b2b61eba295e188dc834d5cb63fc21adb82d9a.zip
A regress test for accessing long long on a long aligned, but not long long
aligned, boundary on 32 bit systems. Written a while ago for m88k, eventually turned into a real regress test.
-rw-r--r--regress/sys/kern/Makefile16
-rw-r--r--regress/sys/kern/unalign/Makefile5
-rw-r--r--regress/sys/kern/unalign/unalign.c45
3 files changed, 59 insertions, 7 deletions
diff --git a/regress/sys/kern/Makefile b/regress/sys/kern/Makefile
index d81fb047091..5b039fe584d 100644
--- a/regress/sys/kern/Makefile
+++ b/regress/sys/kern/Makefile
@@ -1,11 +1,13 @@
-# $OpenBSD: Makefile,v 1.48 2005/04/21 17:45:52 miod Exp $
+# $OpenBSD: Makefile,v 1.49 2005/04/26 21:37:00 miod Exp $
-SUBDIR+= execve getrusage kqueue mmap mmap2 mmap3 dup2 minherit rlimit-file
-SUBDIR+= fcntl_dup dup2_self ptmget pread preadv exit wait mbuf pwrite pwritev
-SUBDIR+= syscall __syscall unfdpass accept nanosleep sysvmsg sysvsem
-SUBDIR+= sysvshm gettimeofday signal exec_self noexec signal-stress
-SUBDIR+= rcvtimeo itimer extent
-#SUBDIR+= mquery rfork
+SUBDIR+= __syscall accept dup2 dup2_self exec_self execve exit extent
+SUBDIR+= fcntl_dup getrusage gettimeofday itimer kqueue mbuf minherit
+SUBDIR+= mmap mmap2 mmap3
+#SUBDIR+= mquery
+SUBDIR+= nanosleep noexec pread preadv ptmget pwrite pwritev rcvtimeo
+#SUBDIR+= rfork
+SUBDIR+= rlimit-file signal signal-stress syscall sysvmsg sysvsem
+SUBDIR+= sysvshm unalign unfdpass wait
install:
diff --git a/regress/sys/kern/unalign/Makefile b/regress/sys/kern/unalign/Makefile
new file mode 100644
index 00000000000..1e0055985ec
--- /dev/null
+++ b/regress/sys/kern/unalign/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2005/04/26 21:37:05 miod Exp $
+
+PROG= unalign
+
+.include <bsd.regress.mk>
diff --git a/regress/sys/kern/unalign/unalign.c b/regress/sys/kern/unalign/unalign.c
new file mode 100644
index 00000000000..7721d01b54f
--- /dev/null
+++ b/regress/sys/kern/unalign/unalign.c
@@ -0,0 +1,45 @@
+/* $OpenBSD: unalign.c,v 1.1 2005/04/26 21:37:05 miod Exp $ */
+/* Written by Miod Vallat, 2004 AD -- this file is in the public domain */
+
+/*
+ * This test checks for the ability, for 32 bit systems, to correctly
+ * access a long long (64 bit) value aligned on a 32 bit boundary, but not
+ * on a 64 bit boundary.
+ *
+ * All architectures should pass this test; on m88k this requires assistance
+ * from the kernel to recover from the misaligned operand exception: see
+ * double_reg_fixup() in arch/m88k/m88k/trap.c for details.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+
+int
+main(int argc, char *argv[])
+{
+#if !defined(__LP64__)
+ long array[4] = { 0x12345678, 0x13579ace, 0xffffabcd, 0x2468fedc };
+ long long t;
+ unsigned int i;
+
+ t = *(long long *)(array + 1);
+#if BYTE_ORDER == BIG_ENDIAN
+ if (t != 0x13579aceffffabcdULL)
+#else
+ if (t != 0xffffabcd13579aceULL)
+#endif
+ return (1);
+
+ t = 0xdeadbeaffadebabeULL;
+ *(long long *)(array + 1) = t;
+
+#if BYTE_ORDER == BIG_ENDIAN
+ if (array[1] != 0xdeadbeaf || array[2] != 0xfadebabe)
+#else
+ if (array[1] != 0xfadebabe || array[2] != 0xdeadbeaf)
+#endif
+ return (1);
+
+#endif /* __LP64__ */
+ return (0);
+}