Mercurial > octave
view liboctave/system/mach-info.cc @ 21202:f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
* Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc,
Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc,
Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc,
CNDArray.cc, CRowVector.cc, CSparse.cc, CSparse.h, DiagArray2.cc, MArray-C.cc,
MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc,
MDiagArray2.cc, MSparse-C.cc, MSparse-d.cc, MSparse.h, MatrixType.cc,
PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc,
boolMatrix.cc, boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc,
dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc,
dSparse.cc, dSparse.h, dim-vector.cc, fCColVector.cc, fCDiagMatrix.cc,
fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc,
fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, int16NDArray.cc,
int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, intNDArray.cc,
uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc,
blaswrap.c, cquit.c, f77-extern.cc, f77-fcn.c, f77-fcn.h, lo-error.c, quit.cc,
quit.h, CmplxAEPBAL.cc, CmplxCHOL.cc, CmplxGEPBAL.cc, CmplxHESS.cc, CmplxLU.cc,
CmplxQR.cc, CmplxQRP.cc, CmplxSCHUR.cc, CmplxSVD.cc, CollocWt.cc, DASPK.cc,
DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, base-lu.cc, base-qr.cc,
dbleAEPBAL.cc, dbleCHOL.cc, dbleGEPBAL.cc, dbleHESS.cc, dbleLU.cc, dbleQR.cc,
dbleQRP.cc, dbleSCHUR.cc, dbleSVD.cc, eigs-base.cc, fCmplxAEPBAL.cc,
fCmplxCHOL.cc, fCmplxGEPBAL.cc, fCmplxHESS.cc, fCmplxLU.cc, fCmplxQR.cc,
fCmplxQRP.cc, fCmplxSCHUR.cc, fCmplxSVD.cc, fEIG.cc, floatAEPBAL.cc,
floatCHOL.cc, floatGEPBAL.cc, floatHESS.cc, floatLU.cc, floatQR.cc,
floatQRP.cc, floatSCHUR.cc, floatSVD.cc, lo-mappers.cc, lo-specfun.cc,
oct-convn.cc, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-rand.cc,
oct-spparms.cc, randgamma.c, randmtzig.c, randpoisson.c, sparse-chol.cc,
sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, mx-defs.h, dir-ops.cc,
file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc,
oct-group.cc, oct-openmp.h, oct-passwd.cc, oct-syscalls.cc, oct-time.cc,
oct-uname.cc, pathlen.h, sysdir.h, syswait.h, cmd-edit.cc, cmd-hist.cc,
data-conv.cc, f2c-main.c, glob-match.cc, lo-array-errwarn.cc,
lo-array-gripes.cc, lo-cutils.c, lo-cutils.h, lo-ieee.cc, lo-math.h,
lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc, oct-inttypes.cc,
oct-inttypes.h, oct-locbuf.cc, oct-mutex.cc, oct-refcount.h, oct-rl-edit.c,
oct-rl-hist.c, oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc,
sparse-sort.cc, sparse-util.cc, statdefs.h, str-vec.cc, unwind-prot.cc,
url-transfer.cc, display-available.h, main-cli.cc, main-gui.cc, main.in.cc,
mkoctfile.in.cc, octave-config.in.cc, shared-fcns.h:
indent #ifdef blocks in liboctave and src directories.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 06 Feb 2016 06:40:13 -0800 |
parents | 7cac4e7458f2 |
children | 40de9f8f23a6 |
line wrap: on
line source
/* Copyright (C) 1996-2015 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/>. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include "f77-fcn.h" #include "lo-error.h" #include "mach-info.h" #include "singleton-cleanup.h" extern "C" { double F77_FUNC (d1mach, D1MACH) (const octave_idx_type&); } oct_mach_info *oct_mach_info::instance = 0; union equiv { double d; int i[2]; }; struct float_params { oct_mach_info::float_format fp_fmt; equiv fp_par[4]; }; #define INIT_FLT_PAR(fp, fmt, sm1, sm2, lrg1, lrg2, rt1, rt2, dv1, dv2) \ do \ { \ fp.fp_fmt = (fmt); \ fp.fp_par[0].i[0] = (sm1); fp.fp_par[0].i[1] = (sm2); \ fp.fp_par[1].i[0] = (lrg1); fp.fp_par[1].i[1] = (lrg2); \ fp.fp_par[2].i[0] = (rt1); fp.fp_par[2].i[1] = (rt2); \ fp.fp_par[3].i[0] = (dv1); fp.fp_par[3].i[1] = (dv2); \ } \ while (0) static int equiv_compare (const equiv *std, const equiv *v, int len) { int i; for (i = 0; i < len; i++) if (v[i].i[0] != std[i].i[0] || v[i].i[1] != std[i].i[1]) return 0; return 1; } static oct_mach_info::float_format get_float_format (void) { oct_mach_info::float_format retval = oct_mach_info::flt_fmt_unknown; float_params fp[5]; INIT_FLT_PAR (fp[0], oct_mach_info::flt_fmt_ieee_big_endian, 1048576, 0, 2146435071, -1, 1017118720, 0, 1018167296, 0); INIT_FLT_PAR (fp[1], oct_mach_info::flt_fmt_ieee_little_endian, 0, 1048576, -1, 2146435071, 0, 1017118720, 0, 1018167296); INIT_FLT_PAR (fp[4], oct_mach_info::flt_fmt_unknown, 0, 0, 0, 0, 0, 0, 0, 0); equiv mach_fp_par[4]; mach_fp_par[0].d = F77_FUNC (d1mach, D1MACH) (1); mach_fp_par[1].d = F77_FUNC (d1mach, D1MACH) (2); mach_fp_par[2].d = F77_FUNC (d1mach, D1MACH) (3); mach_fp_par[3].d = F77_FUNC (d1mach, D1MACH) (4); int i = 0; do { if (equiv_compare (fp[i].fp_par, mach_fp_par, 4)) { retval = fp[i].fp_fmt; break; } } while (fp[++i].fp_fmt != oct_mach_info::flt_fmt_unknown); return retval; } static bool ten_little_endians (void) { // Are we little or big endian? From Harbison & Steele. union { long l; char c[sizeof (long)]; } u; u.l = 1; return (u.c[sizeof (long) - 1] == 1); } oct_mach_info::oct_mach_info (void) : native_float_fmt (get_float_format ()), big_chief (ten_little_endians ()) { } bool oct_mach_info::instance_ok (void) { bool retval = true; if (! instance) { instance = new oct_mach_info (); if (instance) singleton_cleanup_list::add (cleanup_instance); } if (! instance) (*current_liboctave_error_handler) ("unable to create command history object!"); return retval; } oct_mach_info::float_format oct_mach_info::native_float_format (void) { return (instance_ok ()) ? instance->native_float_fmt : oct_mach_info::flt_fmt_unknown; } bool oct_mach_info::words_big_endian (void) { return (instance_ok ()) ? instance->big_chief : false; } bool oct_mach_info::words_little_endian (void) { return (instance_ok ()) ? (! instance->big_chief) : false; } oct_mach_info::float_format oct_mach_info::string_to_float_format (const std::string& s) { oct_mach_info::float_format retval = oct_mach_info::flt_fmt_unknown; if (s == "native" || s == "n") retval = oct_mach_info::native_float_format (); else if (s == "ieee-be" || s == "b") retval = oct_mach_info::flt_fmt_ieee_big_endian; else if (s == "ieee-le" || s == "l") retval = oct_mach_info::flt_fmt_ieee_little_endian; else if (s == "unknown") retval = oct_mach_info::flt_fmt_unknown; else (*current_liboctave_error_handler) ("invalid architecture type specified"); return retval; } std::string oct_mach_info::float_format_as_string (float_format flt_fmt) { std::string retval = "unknown"; switch (flt_fmt) { case flt_fmt_ieee_big_endian: retval = "ieee-be"; break; case flt_fmt_ieee_little_endian: retval = "ieee-le"; break; default: break; } return retval; }