1 ## Copyright (C) 2004-2012 John W. Eaton
3 ## This file is part of Octave.
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
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {[@var{c}, @var{maxsize}, @var{endian}] =} computer ()
21 ## @deftypefnx {Function File} {@var{arch} =} computer ("arch")
22 ## Print or return a string of the form @var{cpu}-@var{vendor}-@var{os}
23 ## that identifies the kind of computer Octave is running on. If invoked
24 ## with an output argument, the value is returned instead of printed. For
30 ## @print{} i586-pc-linux-gnu
33 ## @result{} x = "i586-pc-linux-gnu"
37 ## If two output arguments are requested, also return the maximum number
38 ## of elements for an array.
40 ## If three output arguments are requested, also return the byte order
41 ## of the current system as a character (@code{"B"} for big-endian or
42 ## @code{"L"} for little-endian).
44 ## If the argument @code{"arch"} is specified, return a string
45 ## indicating the architecture of the computer on which Octave is
49 function [c, maxsize, endian] = computer (a)
51 if (nargin == 1 && ischar (a) && strcmpi (a, "arch"))
52 tmp = strsplit (octave_config_info ("canonical_host_type"), "-");
54 c = sprintf ("%s-%s-%s", tmp{4}, tmp{3}, tmp{1});
56 c = sprintf ("%s-%s", tmp{3}, tmp{1});
59 msg = octave_config_info ("canonical_host_type");
61 if (strcmp (msg, "unknown"))
62 msg = "Hi Dave, I'm a HAL-9000";
69 if (strcmp (octave_config_info ("USE_64_BIT_IDX_T"), "true"))
74 if (octave_config_info ("words_big_endian"))
76 elseif (octave_config_info ("words_little_endian"))
88 %!assert((ischar (computer ())
89 %! && computer () == octave_config_info ("canonical_host_type")));
90 %!assert(ischar (computer ("arch")));