view liboctave/wrappers/fpucw-wrapper.h @ 21894:67a5cb9cd941

hide gnulib fpucw header * liboctave/wrappers/fpucw-wrapper.c, liboctave/wrappers/fpucw-wrapper.h: New files. * liboctave/wrappers/module.mk: Update. * ov-java.cc: Use new octave_set_default_fpucw function. * oct-inttypes.cc: Don't include fpucw.h. diff --git a/libinterp/octave-value/ov-java.cc b/libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc +++ b/libinterp/octave-value/ov-java.cc @@ -27,11 +27,7 @@ along with Octave; see the file COPYING. #include "defun.h" #include "error.h" #include "errwarn.h" -#include "fpucw.h" - -#if defined (HAVE_FPU_CONTROL_H) -# include <fpu_control.h> -#endif +#include "fpucw-wrapper.h" #if defined (HAVE_WINDOWS_H) # include <windows.h> @@ -508,23 +504,6 @@ initial_class_path (void) return retval; } -#if ! defined (_FPU_DEFAULT) -# if defined __i386__ || defined __x86_64__ -# define _FPU_DEFAULT 0x037f -# else -# define _FPU_DEFAULT 0 -# endif -#endif - -static void -restore_fpu_state (void) -{ - fpucw_t cw = GET_FPUCW (); - - if (cw != _FPU_DEFAULT) - SET_FPUCW (_FPU_DEFAULT); -} - static void initialize_jvm (void) { @@ -726,7 +705,7 @@ terminate_jvm (void) if (jvm_lib) jvm_lib.close (); - restore_fpu_state (); + octave_set_default_fpucw (); } } @@ -951,7 +930,7 @@ compute_array_dimensions (JNIEnv *jni_en idx++; } - restore_fpu_state (); + octave_set_default_fpucw (); return dv; } @@ -1005,7 +984,7 @@ get_array_elements (JNIEnv *jni_env, job else retval = check_exception (jni_env); - restore_fpu_state (); + octave_set_default_fpucw (); return retval; } @@ -1035,7 +1014,7 @@ set_array_elements (JNIEnv *jni_env, job else retval = check_exception (jni_env); - restore_fpu_state (); + octave_set_default_fpucw (); return retval; } @@ -1076,7 +1055,7 @@ get_invoke_list (JNIEnv *jni_env, void * name_list.push_back (jstring_to_string (jni_env, fieldName)); } - restore_fpu_state (); + octave_set_default_fpucw (); } string_vector v (name_list); @@ -1132,7 +1111,7 @@ convert_to_string (JNIEnv *jni_env, jobj else error ("unable to convert Java object to string"); - restore_fpu_state (); + octave_set_default_fpucw (); } return retval; @@ -1401,7 +1380,7 @@ box_more (JNIEnv *jni_env, void *jobj_ar if (retval.is_undefined ()) retval = octave_value (new octave_java (jobj, jcls)); - restore_fpu_state (); + octave_set_default_fpucw (); return retval; } @@ -1685,7 +1664,7 @@ java_event_hook (void) jmethodID mID = current_env->GetStaticMethodID (cls, "checkPendingAction", "()V"); current_env->CallStaticVoidMethod (cls, mID); - restore_fpu_state (); + octave_set_default_fpucw (); } return 0; @@ -1712,7 +1691,7 @@ initialize_java (void) error (msg.c_str ()); } - restore_fpu_state (); + octave_set_default_fpucw (); } } @@ -2159,7 +2138,7 @@ octave_java::do_javaMethod (void *jni_en retval = check_exception (jni_env); } - restore_fpu_state (); + octave_set_default_fpucw (); } return retval; @@ -2228,7 +2207,7 @@ octave_java:: do_javaMethod (void *jni_e retval = check_exception (jni_env); } - restore_fpu_state (); + octave_set_default_fpucw (); } return retval; @@ -2300,7 +2279,7 @@ octave_java::do_javaObject (void *jni_en check_exception (jni_env); } - restore_fpu_state (); + octave_set_default_fpucw (); } return retval; @@ -2362,7 +2341,7 @@ octave_java::do_java_get (void *jni_env_ else retval = check_exception (jni_env); - restore_fpu_state (); + octave_set_default_fpucw (); } return retval; @@ -2423,7 +2402,7 @@ octave_java::do_java_get (void *jni_env_ else retval = check_exception (jni_env); - restore_fpu_state (); + octave_set_default_fpucw (); } return retval; @@ -2487,7 +2466,7 @@ octave_java::do_java_set (void *jni_env_ check_exception (jni_env); } - restore_fpu_state (); + octave_set_default_fpucw (); } return retval; @@ -2552,7 +2531,7 @@ octave_java::do_java_set (void *jni_env_ check_exception (jni_env); } - restore_fpu_state (); + octave_set_default_fpucw (); } return retval; diff --git a/liboctave/util/oct-inttypes.cc b/liboctave/util/oct-inttypes.cc --- a/liboctave/util/oct-inttypes.cc +++ b/liboctave/util/oct-inttypes.cc @@ -25,8 +25,6 @@ along with Octave; see the file COPYING. # include "config.h" #endif -#include <fpucw.h> - #include "lo-error.h" #include "oct-inttypes.h" diff --git a/liboctave/wrappers/fpucw-wrapper.c b/liboctave/wrappers/fpucw-wrapper.c new file mode 100644 --- /dev/null +++ b/liboctave/wrappers/fpucw-wrapper.c @@ -0,0 +1,55 @@ +/* + +Copyright (C) 2016 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave 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 +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +// The fpucw macros are provided by gnulib. We don't include gnulib +// headers directly in Octave's C++ source files to avoid problems that +// may be caused by the way that gnulib overrides standard library +// functions. + +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + +#if defined (HAVE_FPU_CONTROL_H) +# include <fpu_control.h> +#endif + +#include "fpucw.h" + +#include "fpucw-wrapper.h" + +#if ! defined (_FPU_DEFAULT) +# if defined __i386__ || defined __x86_64__ +# define _FPU_DEFAULT 0x037f +# else +# define _FPU_DEFAULT 0 +# endif +#endif + +void +octave_set_default_fpucw (void) +{ + fpucw_t cw = GET_FPUCW (); + + if (cw != _FPU_DEFAULT) + SET_FPUCW (_FPU_DEFAULT); +} diff --git a/liboctave/wrappers/fpucw-wrapper.h b/liboctave/wrappers/fpucw-wrapper.h new file mode 100644 --- /dev/null +++ b/liboctave/wrappers/fpucw-wrapper.h @@ -0,0 +1,39 @@ +/* + +Copyright (C) 2016 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave 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 +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#if ! defined (octave_fpucw_wrapper_h) +#define octave_fpucw_wrapper_h 1 + +#if defined __cplusplus +extern "C" { +#endif + +/* For now, all we need to be able to do is set the control word to + the default value. */ + +extern void octave_set_default_fpucw (void); + +#if defined __cplusplus +} +#endif + +#endif diff --git a/liboctave/wrappers/module.mk b/liboctave/wrappers/module.mk --- a/liboctave/wrappers/module.mk +++ b/liboctave/wrappers/module.mk @@ -1,6 +1,7 @@ NOINSTALL_WRAPPERS_INC = \ liboctave/wrappers/base64-wrappers.h \ liboctave/wrappers/canonicalize-file-name-wrapper.h \ + liboctave/wrappers/fpucw-wrapper.h \ liboctave/wrappers/gen-tempname-wrapper.h \ liboctave/wrappers/hash-wrappers.h \ liboctave/wrappers/mkostemp-wrapper.h \ @@ -16,6 +17,7 @@ NOINSTALL_WRAPPERS_INC = \ WRAPPERS_SRC = \ liboctave/wrappers/base64-wrappers.c \ liboctave/wrappers/canonicalize-file-name-wrapper.c \ + liboctave/wrappers/fpucw-wrapper.c \ liboctave/wrappers/gen-tempname-wrapper.c \ liboctave/wrappers/hash-wrappers.c \ liboctave/wrappers/mkostemp-wrapper.c \
author John W. Eaton <jwe@octave.org>
date Tue, 14 Jun 2016 10:47:10 -0400
parents
children
line wrap: on
line source

/*

Copyright (C) 2016 John W. Eaton

This file is part of Octave.

Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

Octave 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
for more details.

You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING.  If not, see
<http://www.gnu.org/licenses/>.

*/

#if ! defined (octave_fpucw_wrapper_h)
#define octave_fpucw_wrapper_h 1

#if defined __cplusplus
extern "C" {
#endif

/* For now, all we need to be able to do is set the control word to
   the default value.  */

extern void octave_set_default_fpucw (void);

#if defined __cplusplus
}
#endif

#endif