xref: /titanic_41/usr/src/lib/libc/port/gen/getisax.c (revision 6185db853e024a486ff8837e6784dd290d866112)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*LINTLIBRARY*/
30 
31 #pragma weak getisax = _getisax
32 #include "synonyms.h"
33 
34 #include <sys/types.h>
35 #include <sys/auxv.h>
36 
37 extern long ___getauxval(int type);
38 
39 /*
40  * Return the 'hwcap' vector of bits in the AT_SUN_HWCAP aux vector entry.
41  *
42  * At this time, the worst-case implementation only uses 13 bits, but for
43  * future-proofing, we allow the interface to describe an arbitrary length
44  * array of 32-bit words.
45  *
46  * As a convenience, the routine returns the maximum number of array alements
47  * that may contain non-zero values.
48  */
49 uint_t
50 getisax(uint32_t *array, uint_t n)
51 {
52 	int i;
53 	static uint32_t auxv_hwcap;
54 
55 	if (auxv_hwcap == 0)
56 		auxv_hwcap = (uint32_t)___getauxval(AT_SUN_HWCAP);
57 
58 	if (n > 0) {
59 		if (n >= 1)
60 			array[0] = auxv_hwcap;
61 		for (i = 1; i < n; i++)
62 			array[i] = 0;
63 	}
64 	return (auxv_hwcap == 0 ? 0 : 1);
65 }
66