GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
mach-info.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "f77-fcn.h"
28 #include "lo-error.h"
29 #include "mach-info.h"
30 
31 extern "C"
32 {
33  int octave_get_float_format (void);
34 
35  int octave_is_big_endian (void);
36 }
37 
38 namespace octave
39 {
40  namespace mach_info
41  {
43  {
44  switch (octave_get_float_format ())
45  {
46  case 1:
48 
49  case 2:
51 
52  default:
53  return flt_fmt_unknown;
54  }
55  }
56 
57  static bool is_big_endian (void)
58  {
59  return octave_is_big_endian ();
60  }
61 
63  {
64  static float_format fmt = get_float_format ();
65 
66  return fmt;
67  }
68 
69  bool words_big_endian (void)
70  {
71  static bool big_endian = is_big_endian ();
72 
73  return big_endian;
74  }
75 
76  bool words_little_endian (void)
77  {
78  static bool little_endian = ! is_big_endian ();
79 
80  return little_endian;
81  }
82 
84  {
86 
87  if (s == "native" || s == "n")
89  else if (s == "ieee-be" || s == "b")
91  else if (s == "ieee-le" || s == "l")
93  else if (s == "unknown")
95  else
97  ("invalid architecture type specified");
98 
99  return retval;
100  }
101 
103  {
104  std::string retval = "unknown";
105 
106  switch (flt_fmt)
107  {
109  retval = "ieee-be";
110  break;
111 
113  retval = "ieee-le";
114  break;
115 
116  default:
117  break;
118  }
119 
120  return retval;
121  }
122  }
123 }
static bool is_big_endian(void)
Definition: mach-info.cc:57
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
Definition: lo-error.c:38
float_format string_to_float_format(const std::string &s)
Definition: mach-info.cc:83
int octave_get_float_format(void)
Definition: cmach-info.c:74
octave::mach_info::float_format flt_fmt
Definition: load-save.cc:736
int octave_is_big_endian(void)
Definition: cmach-info.c:129
s
Definition: file-io.cc:2729
float_format native_float_format(void)
Definition: mach-info.cc:62
octave_value retval
Definition: data.cc:6246
bool words_big_endian(void)
Definition: mach-info.cc:69
static float_format get_float_format(void)
Definition: mach-info.cc:42
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
bool words_little_endian(void)
Definition: mach-info.cc:76
std::string float_format_as_string(float_format flt_fmt)
Definition: mach-info.cc:102