Mercurial > octave
changeset 25681:bef21ac72618 stable
eliminate unnecessary sun-utils.h header file
* Quad.cc: Don't include sun-utils.h
(quad_fcn_ptr, quad_float_fcn_ptr): Declare using references instead
of pointers.
(user_function, float_user_function): Pass X and RESULT by reference
instead of using pointers. Eliminate unnecessary code for accessing
doubles via pointers on Sparc systems.
* sun-utils.h: Delete.
* liboctave/util/module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 26 Jul 2018 15:30:51 -0400 |
parents | 61f8d94f6bbb |
children | 54e79a3785d7 bbbf0d961a94 |
files | liboctave/numeric/Quad.cc liboctave/util/module.mk liboctave/util/sun-utils.h |
diffstat | 3 files changed, 6 insertions(+), 84 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/numeric/Quad.cc Thu Jul 26 12:08:25 2018 -0700 +++ b/liboctave/numeric/Quad.cc Thu Jul 26 15:30:51 2018 -0400 @@ -31,7 +31,6 @@ #include "f77-fcn.h" #include "lo-error.h" #include "quit.h" -#include "sun-utils.h" static integrand_fcn user_fcn; static float_integrand_fcn float_user_fcn; @@ -41,8 +40,8 @@ // function, and the user wants us to quit. int quad_integration_error = 0; -typedef F77_INT (*quad_fcn_ptr) (double*, int&, double*); -typedef F77_INT (*quad_float_fcn_ptr) (float*, int&, float*); +typedef F77_INT (*quad_fcn_ptr) (const double&, int&, double&); +typedef F77_INT (*quad_float_fcn_ptr) (const float&, int&, float&); extern "C" { @@ -80,25 +79,13 @@ } static F77_INT -user_function (double *x, int& ierr, double *result) +user_function (const double& x, int& ierr, double& result) { BEGIN_INTERRUPT_WITH_EXCEPTIONS; -#if defined (__sparc) && defined (__GNUC__) - double xx = access_double (x); -#else - double xx = *x; -#endif - quad_integration_error = 0; - double xresult = (*user_fcn) (xx); - -#if defined (__sparc) && defined (__GNUC__) - assign_double (result, xresult); -#else - *result = xresult; -#endif + result = (*user_fcn) (x); if (quad_integration_error) ierr = -1; @@ -109,13 +96,13 @@ } static F77_INT -float_user_function (float *x, int& ierr, float *result) +float_user_function (const float& x, int& ierr, float& result) { BEGIN_INTERRUPT_WITH_EXCEPTIONS; quad_integration_error = 0; - *result = (*float_user_fcn) (*x); + result = (*float_user_fcn) (x); if (quad_integration_error) ierr = -1;
--- a/liboctave/util/module.mk Thu Jul 26 12:08:25 2018 -0700 +++ b/liboctave/util/module.mk Thu Jul 26 15:30:51 2018 -0400 @@ -40,7 +40,6 @@ %reldir%/sparse-sort.h \ %reldir%/sparse-util.h \ %reldir%/str-vec.h \ - %reldir%/sun-utils.h \ %reldir%/unwind-prot.h \ %reldir%/url-transfer.h
--- a/liboctave/util/sun-utils.h Thu Jul 26 12:08:25 2018 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - -Copyright (C) 1993-2018 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 -<https://www.gnu.org/licenses/>. - -*/ - -#if ! defined (octave_sun_utils_h) -#define octave_sun_utils_h 1 - -#include "octave-config.h" - -// This is only needed to dereference pointers to doubles if mixing -// GCC and Sun SPARC f77/cc compiled code. See the GCC manual (where the -// function access_double() is described) and the Sun f77 manual, -// which explains that doubles are not always aligned on 8 byte -// boundaries. - -#if defined (__sparc) && defined (__GNUC__) - -inline double -access_double (double *unaligned_ptr) -{ - union d2i { double d; int i[2]; }; - - union d2i *p = (union d2i *) unaligned_ptr; - union d2i u; - - u.i[0] = p->i[0]; - u.i[1] = p->i[1]; - - return u.d; -} - -inline void -assign_double (double *unaligned_ptr, double value) -{ - union d2i { double d; int i[2]; }; - - double *ptr = &value; - union d2i *v = (union d2i *) ptr; - union d2i *p = (union d2i *) unaligned_ptr; - - p->i[0] = v->i[0]; - p->i[1] = v->i[1]; -} - -#endif -#endif