# HG changeset patch # User ctornqvi # Date 1449771872 18000 # Thu Dec 10 13:24:32 2015 -0500 # Node ID e1ebd345b88b717a17446fcb6ecf2840ca317aac # Parent 6fd48e4b0fc87d1b8502cf923b98456ab36ef687 [mq]: WindowsExceptionFilter diff -r 6fd48e4b0fc8 -r e1ebd345b88b make/test/JtregNative.gmk --- a/make/test/JtregNative.gmk Thu Dec 10 12:14:46 2015 -0500 +++ b/make/test/JtregNative.gmk Thu Dec 10 13:24:32 2015 -0500 @@ -45,6 +45,7 @@ $(HOTSPOT_TOPDIR)/test/runtime/jni/8025979 \ $(HOTSPOT_TOPDIR)/test/runtime/jni/8033445 \ $(HOTSPOT_TOPDIR)/test/runtime/jni/ToStringInInterfaceTest \ + $(HOTSPOT_TOPDIR)/test/runtime/jni/FloatingPointExceptionFilter \ $(HOTSPOT_TOPDIR)/test/runtime/SameObject \ # diff -r 6fd48e4b0fc8 -r e1ebd345b88b test/runtime/jni/FloatingPointExceptionFilter/FloatingPointExceptionFilter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/jni/FloatingPointExceptionFilter/FloatingPointExceptionFilter.java Thu Dec 10 13:24:32 2015 -0500 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @run main/native FloatingPointExceptionFilter + */ + +public class FloatingPointExceptionFilter +{ + private static final int FPU_DEFAULT = 0x00000037f; + private static final int FPU_IEM = 0x00000080; + private static final int EM_ZERODIVIDE = 0x00000008; + public static volatile float zero = 0.0f; + public static volatile int zeroint = 0; + + public static void main( String[] argv ) throws Exception { + System.loadLibrary("ExceptionFilter"); + setCW( (FPU_DEFAULT | FPU_IEM) & ~EM_ZERODIVIDE ); + zero = 1.0f / zero; + } + + public static native void setCW( int cw ); +} diff -r 6fd48e4b0fc8 -r e1ebd345b88b test/runtime/jni/FloatingPointExceptionFilter/libExceptionFilter.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/jni/FloatingPointExceptionFilter/libExceptionFilter.c Thu Dec 10 13:24:32 2015 -0500 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include +#include + +// header file exists on all linux platforms +#if defined( __linux__ ) || defined( __i386__ ) && defined( HAVE_FPU_CONTROL_H ) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEXPORT void JNICALL Java_FloatingPointExceptionFilter_setCW( + JNIEnv * env, + jclass klazz, + jint cw + ) +{ +// Only valid for specific x86 based systems: linux-x86, or else x86 with fpu_control.h +#if (defined( __linux__ ) && defined( __i386__ )) || (defined( __i386__ ) && defined( HAVE_FPU_CONTROL_H )) +_FPU_SETCW(cw); +#elif defined( _WIN32 ) +_controlfp(cw, 0xffffffff); +} +#endif + +#ifdef __cplusplus +} +#endif