annotate liboctave/system/mach-info.cc @ 27919:1891570abac8

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2020.
author John W. Eaton <jwe@octave.org>
date Mon, 06 Jan 2020 22:29:51 -0500
parents b442ec6dda5c
children bd51beb6205e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
1 /*
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
2
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 Copyright (C) 1996-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
5 See the file COPYRIGHT.md in the top-level directory of this distribution
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
6 or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
7
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
8
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
9 This file is part of Octave.
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
10
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23820
diff changeset
11 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23820
diff changeset
13 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 (at your option) any later version.
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
15
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
16 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
17 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
19 GNU General Public License for more details.
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
20
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
21 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5775
diff changeset
22 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23820
diff changeset
23 <https://www.gnu.org/licenses/>.
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
24
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
25 */
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
26
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
27 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
28 # include "config.h"
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
29 #endif
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
30
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
31 #include "f77-fcn.h"
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
32 #include "lo-error.h"
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
33 #include "mach-info.h"
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
34
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
35 extern "C"
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
36 {
23820
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
37 int octave_get_float_format (void);
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
38
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
39 int octave_is_big_endian (void);
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
40 }
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
41
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
42 namespace octave
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
43 {
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
44 namespace mach_info
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
45 {
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
46 static float_format get_float_format (void)
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
47 {
23820
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
48 switch (octave_get_float_format ())
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
49 {
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
50 case 1:
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
51 return flt_fmt_ieee_little_endian;
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
52
23820
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
53 case 2:
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
54 return flt_fmt_ieee_big_endian;
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
55
23820
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
56 default:
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
57 return flt_fmt_unknown;
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
58 }
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
59 }
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
60
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
61 static bool is_big_endian (void)
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
62 {
23820
1a08d0ac510f move union field type punning code to C (bug #51638)
John W. Eaton <jwe@octave.org>
parents: 23745
diff changeset
63 return octave_is_big_endian ();
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
64 }
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
65
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
66 float_format native_float_format (void)
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
67 {
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
68 static float_format fmt = get_float_format ();
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
69
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
70 return fmt;
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
71 }
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2847
diff changeset
72
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
73 bool words_big_endian (void)
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
74 {
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
75 static bool big_endian = is_big_endian ();
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
76
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
77 return big_endian;
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
78 }
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
79
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
80 bool words_little_endian (void)
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
81 {
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
82 static bool little_endian = ! is_big_endian ();
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
83
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
84 return little_endian;
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
85 }
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
86
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
87 float_format string_to_float_format (const std::string& s)
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
88 {
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
89 float_format retval = flt_fmt_unknown;
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
90
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
91 if (s == "native" || s == "n")
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
92 retval = native_float_format ();
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
93 else if (s == "ieee-be" || s == "b")
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
94 retval = flt_fmt_ieee_big_endian;
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
95 else if (s == "ieee-le" || s == "l")
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
96 retval = flt_fmt_ieee_little_endian;
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
97 else if (s == "unknown")
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
98 retval = flt_fmt_unknown;
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
99 else
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
100 (*current_liboctave_error_handler)
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
101 ("invalid architecture type specified");
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
102
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
103 return retval;
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
104 }
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
105
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
106 std::string float_format_as_string (float_format flt_fmt)
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
107 {
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
108 std::string retval = "unknown";
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
109
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
110 switch (flt_fmt)
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
111 {
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
112 case flt_fmt_ieee_big_endian:
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
113 retval = "ieee-be";
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
114 break;
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
115
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
116 case flt_fmt_ieee_little_endian:
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
117 retval = "ieee-le";
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
118 break;
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
119
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
120 default:
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
121 break;
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
122 }
2317
8c09c04f7747 [project @ 1996-07-14 22:30:15 by jwe]
jwe
parents: 1993
diff changeset
123
23745
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
124 return retval;
a732be902061 don't use singleton pattern for mach_info
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
125 }
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
126 }
1960
285a7f683a4c [project @ 1996-02-16 04:03:01 by jwe]
jwe
parents:
diff changeset
127 }