7017
|
1 ## Copyright (C) 2004, 2005, 2007 John W. Eaton |
4691
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
4691
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
4691
|
18 |
|
19 ## -*- texinfo -*- |
5427
|
20 ## @deftypefn {Function File} {[@var{c}, @var{maxsize}, @var{endian}] =} computer () |
4691
|
21 ## Print or return a string of the form @var{cpu}-@var{vendor}-@var{os} |
|
22 ## that identifies the kind of computer Octave is running on. If invoked |
|
23 ## with an output argument, the value is returned instead of printed. For |
|
24 ## example, |
|
25 ## |
|
26 ## @example |
|
27 ## @group |
|
28 ## computer () |
|
29 ## @print{} i586-pc-linux-gnu |
|
30 ## |
|
31 ## x = computer () |
|
32 ## @result{} x = "i586-pc-linux-gnu" |
|
33 ## @end group |
|
34 ## @end example |
5427
|
35 ## |
|
36 ## If two output arguments are requested, also return the maximum number |
|
37 ## of elements for an array. |
|
38 ## |
|
39 ## If three output arguments are requested, also return the byte order |
|
40 ## of the current system as a character (@code{"B"} for big-endian or |
|
41 ## @code{"L"} for little-endian). |
4691
|
42 ## @end deftypefn |
|
43 |
5427
|
44 function [c, maxsize, endian] = computer () |
4691
|
45 |
|
46 if (nargin != 0) |
|
47 warning ("computer: ignoring extra arguments"); |
|
48 endif |
|
49 |
|
50 msg = octave_config_info ("canonical_host_type"); |
|
51 |
|
52 if (strcmp (msg, "unknown")) |
|
53 msg = "Hi Dave, I'm a HAL-9000"; |
|
54 endif |
|
55 |
|
56 if (nargout == 0) |
|
57 printf ("%s\n", msg); |
|
58 else |
5427
|
59 c = msg; |
|
60 if (strcmp (octave_config_info ("USE_64_BIT_IDX_T"), "true")) |
|
61 maxsize = 2^63-1; |
|
62 else |
|
63 maxsize = 2^31-1; |
|
64 endif |
|
65 if (octave_config_info ("words_big_endian")) |
|
66 endian = "B"; |
|
67 elseif (octave_config_info ("words_little_endian")) |
|
68 endian = "L"; |
|
69 else |
|
70 endian = "?"; |
|
71 endif |
4691
|
72 endif |
|
73 |
|
74 endfunction |