/*****************************************************************************
* cpu.c: CPU detection code
*****************************************************************************
- * Copyright (C) 1998-2004 VideoLAN
+ * Copyright (C) 1998-2004 the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
# include <setjmp.h> /* longjmp, setjmp */
#endif
-#ifdef SYS_DARWIN
+#include "libvlc.h"
+
+#if defined(__APPLE__) && (defined(__ppc__) || defined(__ppc64__))
#include <sys/sysctl.h>
#endif
-#include "vlc_cpu.h"
-
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static jmp_buf env;
static int i_illegal;
#if defined( __i386__ ) || defined( __x86_64__ )
-static char *psz_capability;
+static const char *psz_capability;
#endif
#endif
{
volatile uint32_t i_capabilities = CPU_CAPABILITY_NONE;
-#if defined( SYS_DARWIN )
+#if defined(__APPLE__) && (defined(__ppc__) || defined(__ppc64__))
int selectors[2] = { CTL_HW, HW_VECTORUNIT };
int i_has_altivec = 0;
size_t i_length = sizeof( i_has_altivec );
/* Needed for x86 CPU capabilities detection */
# if defined( __x86_64__ )
# define cpuid( reg ) \
- asm volatile ( "push %%rbx\n\t" \
- "cpuid\n\t" \
+ asm volatile ( "cpuid\n\t" \
"movl %%ebx,%1\n\t" \
- "pop %%rbx\n\t" \
: "=a" ( i_eax ), \
- "=r" ( i_ebx ), \
+ "=b" ( i_ebx ), \
"=c" ( i_ecx ), \
"=d" ( i_edx ) \
: "a" ( reg ) \
# endif
return i_capabilities;
-#elif defined( __powerpc__ )
+#elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
# ifdef CAN_COMPILE_ALTIVEC && defined( HAVE_SIGNAL_H )
void (*pf_sigill) (int) = signal( SIGILL, SigHandler );
}
#endif
+
+uint32_t cpu_flags = 0;
+
+
+/*****************************************************************************
+ * vlc_CPU: get pre-computed CPU capability flags
+ ****************************************************************************/
+unsigned vlc_CPU (void)
+{
+ return cpu_flags;
+}
+