2 * (C) Copyright IBM Corporation 2004
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Check CPU capabilities & initialize optimized funtions for this particular
30 * \author Ian Romanick <idr@us.ibm.com>
35 #include <sys/types.h>
41 unsigned long _mesa_ppc_cpu_features
= 0;
44 * Detect CPU features and install optimized transform and lighting routines.
45 * Currently, CPU features are only detected. The optimized routines have
49 * This routine is highly specific to Linux kernel 2.6. I'm still waiting
50 * to hear back from the glibc folk on how to do this "right".
53 void _mesa_init_all_ppc_transform_asm( void )
56 const pid_t my_pid
= getpid();
65 sprintf( file_name
, "/proc/%u/auxv", (unsigned) my_pid
);
66 f
= fopen( file_name
, "rb" );
69 ssize_t elem
= fread( & v
, sizeof( v
), 1, f
);
75 if ( v
.a_type
== AT_HWCAP
) {
76 _mesa_ppc_cpu_features
= v
.a_un
.a_val
;
85 _mesa_ppc_cpu_features
&= ~PPC_FEATURES_HAS_ALTIVEC
;