Clear the part of fenv that is modified by old AMD Opteron during
authorbluhm <bluhm@openbsd.org>
Mon, 9 Jul 2018 16:20:33 +0000 (16:20 +0000)
committerbluhm <bluhm@openbsd.org>
Mon, 9 Jul 2018 16:20:33 +0000 (16:20 +0000)
process startup.
from guenther@

regress/lib/libm/fenv/fenv.c

index 038b2f9..4de4d86 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: fenv.c,v 1.3 2017/08/07 20:56:46 bluhm Exp $  */
+/*     $OpenBSD: fenv.c,v 1.4 2018/07/09 16:20:33 bluhm Exp $  */
 
 /*-
  * Copyright (c) 2004 David Schultz <das@FreeBSD.org>
@@ -41,6 +41,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <machine/fpu.h>
 
 /*
  * Implementations are permitted to define additional exception flags
@@ -132,6 +133,10 @@ test_dfl_env(void)
        fenv_t env;
 
        fegetenv(&env);
+#ifdef __amd64
+       /* Some early amd64 CPUs set fip+fdp for non-x87 instructions */
+       memset(&env.__x87.__others[0], 0, 14);
+#endif /* __amd64 */
        assert(memcmp(&env, FE_DFL_ENV, sizeof(env)) == 0);
 #endif
        assert(fetestexcept(FE_ALL_EXCEPT) == 0);
@@ -424,7 +429,7 @@ test_feholdupdate(void)
                                 * We don't want to cause a fatal exception in
                                 * the child until the second pass, so we can
                                 * check other properties of feupdateenv().
-                                */                             
+                                */
                                if (pass == 1)
                                        assert((feenableexcept(except) &
                                                   ALL_STD_EXCEPT) == 0);