Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
d4c55a87
Commit
d4c55a87
authored
Mar 20, 2001
by
Sam Hocevar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Altivec instructions autodetection.
parent
81bafafa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
128 additions
and
108 deletions
+128
-108
include/tests.h
include/tests.h
+4
-108
src/interface/main.c
src/interface/main.c
+124
-0
No files found.
include/tests.h
View file @
d4c55a87
...
...
@@ -32,112 +32,8 @@
/*****************************************************************************
* TestVersion: tests if the given string equals the current version
*****************************************************************************/
int
TestVersion
(
char
*
psz_version
);
int
TestProgram
(
char
*
psz_program
);
int
TestMethod
(
char
*
psz_var
,
char
*
psz_method
);
int
TestCPU
(
int
i_capabilities
);
/*****************************************************************************
* CPUCapabilities: list the processors MMX support and other capabilities
*****************************************************************************
* This function is called to list extensions the CPU may have.
*****************************************************************************/
static
__inline__
int
CPUCapabilities
(
void
)
{
#ifdef SYS_BEOS
return
(
CPU_CAPABILITY_NONE
|
CPU_CAPABILITY_486
|
CPU_CAPABILITY_586
|
CPU_CAPABILITY_MMX
);
#else
int
i_capabilities
=
CPU_CAPABILITY_NONE
;
#ifdef __i386__
unsigned
int
i_eax
,
i_ebx
,
i_ecx
,
i_edx
;
boolean_t
b_amd
;
#define cpuid( a ) \
asm volatile ( "cpuid" \
: "=a" ( i_eax ), \
"=b" ( i_ebx ), \
"=c" ( i_ecx ), \
"=d" ( i_edx ) \
: "a" ( a ) \
: "cc" ); \
/* test for a 486 CPU */
asm
volatile
(
"pushfl
popl %%eax
movl %%eax, %%ebx
xorl $0x200000, %%eax
pushl %%eax
popfl
pushfl
popl %%eax"
:
"=a"
(
i_eax
),
"=b"
(
i_ebx
)
:
:
"cc"
);
if
(
i_eax
==
i_ebx
)
{
return
(
i_capabilities
);
}
i_capabilities
|=
CPU_CAPABILITY_486
;
/* the CPU supports the CPUID instruction - get its level */
cpuid
(
0x00000000
);
if
(
!
i_eax
)
{
return
(
i_capabilities
);
}
/* FIXME: this isn't correct, since some 486s have cpuid */
i_capabilities
|=
CPU_CAPABILITY_586
;
/* borrowed from mpeg2dec */
b_amd
=
(
i_ebx
==
0x68747541
)
&&
(
i_ecx
==
0x444d4163
)
&&
(
i_edx
==
0x69746e65
);
/* test for the MMX flag */
cpuid
(
0x00000001
);
if
(
!
(
i_edx
&
0x00800000
)
)
{
return
(
i_capabilities
);
}
i_capabilities
|=
CPU_CAPABILITY_MMX
;
if
(
i_edx
&
0x02000000
)
{
i_capabilities
|=
CPU_CAPABILITY_MMXEXT
;
}
/* test for additional capabilities */
cpuid
(
0x80000000
);
if
(
i_eax
<
0x80000001
)
{
return
(
i_capabilities
);
}
/* list these additional capabilities */
cpuid
(
0x80000001
);
if
(
i_edx
&
0x80000000
)
{
i_capabilities
|=
CPU_CAPABILITY_3DNOW
;
}
if
(
b_amd
&&
(
i_edx
&
0x00400000
)
)
{
i_capabilities
|=
CPU_CAPABILITY_MMXEXT
;
}
#endif
/* __i386__ */
return
(
i_capabilities
);
#endif
/* SYS_BEOS */
}
int
TestVersion
(
char
*
psz_version
);
int
TestProgram
(
char
*
psz_program
);
int
TestMethod
(
char
*
psz_var
,
char
*
psz_method
);
int
TestCPU
(
int
i_capabilities
);
src/interface/main.c
View file @
d4c55a87
...
...
@@ -34,6 +34,10 @@
#include <getopt.h>
/* getopt() */
#endif
#ifdef SYS_DARWIN1_3
#include <Carbon/Carbon.h>
/* Altivec detection */
#endif
#include <unistd.h>
#include <errno.h>
/* ENOMEM */
#include <stdlib.h>
/* getenv(), strtol(), */
...
...
@@ -180,6 +184,8 @@ static void InitSignalHandler ( void );
static
void
SimpleSignalHandler
(
int
i_signal
);
static
void
FatalSignalHandler
(
int
i_signal
);
static
int
CPUCapabilities
(
void
);
/*****************************************************************************
* main: parse command line, start interface and spawn threads
*****************************************************************************
...
...
@@ -878,3 +884,121 @@ static void FatalSignalHandler( int i_signal )
p_main
->
p_intf
->
b_die
=
1
;
}
/*****************************************************************************
* CPUCapabilities: list the processors MMX support and other capabilities
*****************************************************************************
* This function is called to list extensions the CPU may have.
*****************************************************************************/
static
int
CPUCapabilities
(
void
)
{
int
i_capabilities
=
CPU_CAPABILITY_NONE
;
#if defined( SYS_BEOS )
i_capabilities
|=
CPU_CAPABILITY_486
|
CPU_CAPABILITY_586
|
CPU_CAPABILITY_MMX
;
#elif defined( SYS_DARWIN1_3 )
OSErr
err
;
long
l_attributes
=
0
;
err
=
Gestalt
(
gestaltPowerPCProcessorFeatures
,
&
l_attributes
);
if
(
err
==
noErr
&&
(
(
1
<<
gestaltPowerPCHasVectorInstructions
)
&
l_attributes
)
)
{
i_capabilities
|=
CPU_CAPABILITY_ALTIVEC
;
}
#elif defined( __i386__ )
unsigned
int
i_eax
,
i_ebx
,
i_ecx
,
i_edx
;
boolean_t
b_amd
;
# define cpuid( a ) \
asm volatile ( "cpuid" \
: "=a" ( i_eax ), \
"=b" ( i_ebx ), \
"=c" ( i_ecx ), \
"=d" ( i_edx ) \
: "a" ( a ) \
: "cc" ); \
/* test for a 486 CPU */
asm
volatile
(
"pushfl
popl %%eax
movl %%eax, %%ebx
xorl $0x200000, %%eax
pushl %%eax
popfl
pushfl
popl %%eax"
:
"=a"
(
i_eax
),
"=b"
(
i_ebx
)
:
:
"cc"
);
if
(
i_eax
==
i_ebx
)
{
return
(
i_capabilities
);
}
i_capabilities
|=
CPU_CAPABILITY_486
;
/* the CPU supports the CPUID instruction - get its level */
cpuid
(
0x00000000
);
if
(
!
i_eax
)
{
return
(
i_capabilities
);
}
/* FIXME: this isn't correct, since some 486s have cpuid */
i_capabilities
|=
CPU_CAPABILITY_586
;
/* borrowed from mpeg2dec */
b_amd
=
(
i_ebx
==
0x68747541
)
&&
(
i_ecx
==
0x444d4163
)
&&
(
i_edx
==
0x69746e65
);
/* test for the MMX flag */
cpuid
(
0x00000001
);
if
(
!
(
i_edx
&
0x00800000
)
)
{
return
(
i_capabilities
);
}
i_capabilities
|=
CPU_CAPABILITY_MMX
;
if
(
i_edx
&
0x02000000
)
{
i_capabilities
|=
CPU_CAPABILITY_MMXEXT
;
}
/* test for additional capabilities */
cpuid
(
0x80000000
);
if
(
i_eax
<
0x80000001
)
{
return
(
i_capabilities
);
}
/* list these additional capabilities */
cpuid
(
0x80000001
);
if
(
i_edx
&
0x80000000
)
{
i_capabilities
|=
CPU_CAPABILITY_3DNOW
;
}
if
(
b_amd
&&
(
i_edx
&
0x00400000
)
)
{
i_capabilities
|=
CPU_CAPABILITY_MMXEXT
;
}
#else
/* default behaviour */
#endif
return
(
i_capabilities
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment