4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/systeminfo.h>
30 #include <sys/utsname.h>
36 * Isalist(1) expansion.
38 * Obtain the native instruction sets executable on this platform and unpack
39 * each element into the isalist descriptor.
44 char info
[SYS_NMLN
], * list
, * ptr
, * optr
;
50 if ((desc
= calloc(1, sizeof (Isa_desc
))) == 0)
54 * If we can't get the isalist() perhaps we've gone back to a release
55 * too old to support it - silently ignore.
57 if ((size
= sysinfo(SI_ISALIST
, info
, SYS_NMLN
)) == -1)
59 desc
->isa_listsz
= (size_t)size
;
62 * Duplicate the isalist string in preparation for breaking it up.
64 if ((list
= strdup(info
)) == 0)
66 desc
->isa_list
= list
;
69 * Determine the number of instruction sets and use this to size the
70 * isalist option table.
72 for (no
= 1, ptr
= list
; *ptr
; ptr
++) {
76 if ((opt
= malloc(no
* sizeof (Isa_opt
))) == 0)
82 * Unpack the instruction set list.
84 for (optr
= ptr
= list
; *ptr
; ptr
++) {
89 opt
->isa_namesz
= ptr
- optr
;
96 opt
->isa_namesz
= ptr
- optr
;
102 * uname(2) expansion.
104 * Obtain the information that identifies the current operating system and
105 * unpack those elements we're interested in (presently name and release).
110 struct utsname utsname
;
114 if ((desc
= calloc(1, sizeof (Uts_desc
))) == 0)
118 * If we can't get the uname(2) silently ignore.
120 if (uname(&utsname
) == -1)
124 * Duplicate the operating system name and release components.
126 size
= strlen(utsname
.sysname
);
127 if ((desc
->uts_osname
= malloc(size
+ 1)) == 0)
129 desc
->uts_osnamesz
= size
;
130 (void) strncpy(desc
->uts_osname
, utsname
.sysname
, size
);
132 size
= strlen(utsname
.release
);
133 if ((desc
->uts_osrel
= malloc(size
+ 1)) == 0)
135 desc
->uts_osrelsz
= size
;
136 (void) strncpy(desc
->uts_osrel
, utsname
.release
, size
);