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
c14e42d7
Commit
c14e42d7
authored
Aug 16, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor CPU detection a little
parent
c051e672
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
53 deletions
+19
-53
src/misc/cpu.c
src/misc/cpu.c
+19
-53
No files found.
src/misc/cpu.c
View file @
c14e42d7
...
@@ -64,20 +64,7 @@ uint32_t CPUCapabilities( void )
...
@@ -64,20 +64,7 @@ uint32_t CPUCapabilities( void )
{
{
volatile
uint32_t
i_capabilities
=
CPU_CAPABILITY_NONE
;
volatile
uint32_t
i_capabilities
=
CPU_CAPABILITY_NONE
;
#if defined(__APPLE__) && (defined(__ppc__) || defined(__ppc64__))
#if defined( __i386__ ) || defined( __x86_64__ )
int
selectors
[
2
]
=
{
CTL_HW
,
HW_VECTORUNIT
};
int
i_has_altivec
=
0
;
size_t
i_length
=
sizeof
(
i_has_altivec
);
int
i_error
=
sysctl
(
selectors
,
2
,
&
i_has_altivec
,
&
i_length
,
NULL
,
0
);
i_capabilities
|=
CPU_CAPABILITY_FPU
;
if
(
i_error
==
0
&&
i_has_altivec
!=
0
)
i_capabilities
|=
CPU_CAPABILITY_ALTIVEC
;
return
i_capabilities
;
#elif defined( __i386__ ) || defined( __x86_64__ )
volatile
unsigned
int
i_eax
,
i_ebx
,
i_ecx
,
i_edx
;
volatile
unsigned
int
i_eax
,
i_ebx
,
i_ecx
,
i_edx
;
volatile
bool
b_amd
;
volatile
bool
b_amd
;
...
@@ -131,12 +118,7 @@ uint32_t CPUCapabilities( void )
...
@@ -131,12 +118,7 @@ uint32_t CPUCapabilities( void )
:
"cc"
);
:
"cc"
);
if
(
i_eax
==
i_ebx
)
if
(
i_eax
==
i_ebx
)
{
goto
out
;
# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW )
signal
(
SIGILL
,
pf_sigill
);
# endif
return
i_capabilities
;
}
# else
# else
/* x86_64 supports cpuid instruction, so we dont need to check it */
/* x86_64 supports cpuid instruction, so we dont need to check it */
# endif
# endif
...
@@ -147,12 +129,7 @@ uint32_t CPUCapabilities( void )
...
@@ -147,12 +129,7 @@ uint32_t CPUCapabilities( void )
cpuid
(
0x00000000
);
cpuid
(
0x00000000
);
if
(
!
i_eax
)
if
(
!
i_eax
)
{
goto
out
;
# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW )
signal
(
SIGILL
,
pf_sigill
);
# endif
return
i_capabilities
;
}
/* FIXME: this isn't correct, since some 486s have cpuid */
/* FIXME: this isn't correct, since some 486s have cpuid */
i_capabilities
|=
CPU_CAPABILITY_586
;
i_capabilities
|=
CPU_CAPABILITY_586
;
...
@@ -165,12 +142,7 @@ uint32_t CPUCapabilities( void )
...
@@ -165,12 +142,7 @@ uint32_t CPUCapabilities( void )
cpuid
(
0x00000001
);
cpuid
(
0x00000001
);
if
(
!
(
i_edx
&
0x00800000
)
)
if
(
!
(
i_edx
&
0x00800000
)
)
{
goto
out
;
# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW )
signal
(
SIGILL
,
pf_sigill
);
# endif
return
i_capabilities
;
}
i_capabilities
|=
CPU_CAPABILITY_MMX
;
i_capabilities
|=
CPU_CAPABILITY_MMX
;
...
@@ -220,12 +192,7 @@ uint32_t CPUCapabilities( void )
...
@@ -220,12 +192,7 @@ uint32_t CPUCapabilities( void )
cpuid
(
0x80000000
);
cpuid
(
0x80000000
);
if
(
i_eax
<
0x80000001
)
if
(
i_eax
<
0x80000001
)
{
goto
out
;
# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW )
signal
(
SIGILL
,
pf_sigill
);
# endif
return
i_capabilities
;
}
/* list these additional capabilities */
/* list these additional capabilities */
cpuid
(
0x80000001
);
cpuid
(
0x80000001
);
...
@@ -254,18 +221,27 @@ uint32_t CPUCapabilities( void )
...
@@ -254,18 +221,27 @@ uint32_t CPUCapabilities( void )
i_capabilities
|=
CPU_CAPABILITY_MMXEXT
;
i_capabilities
|=
CPU_CAPABILITY_MMXEXT
;
}
}
out:
# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW )
# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW )
signal
(
SIGILL
,
pf_sigill
);
signal
(
SIGILL
,
pf_sigill
);
# endif
# endif
return
i_capabilities
;
#elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
#elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
# ifdef CAN_COMPILE_ALTIVEC
void
(
*
pf_sigill
)
(
int
)
=
signal
(
SIGILL
,
SigHandler
);
i_capabilities
|=
CPU_CAPABILITY_FPU
;
i_capabilities
|=
CPU_CAPABILITY_FPU
;
# if defined(__APPLE__)
int
selectors
[
2
]
=
{
CTL_HW
,
HW_VECTORUNIT
};
int
i_has_altivec
=
0
;
size_t
i_length
=
sizeof
(
i_has_altivec
);
int
i_error
=
sysctl
(
selectors
,
2
,
&
i_has_altivec
,
&
i_length
,
NULL
,
0
);
if
(
i_error
==
0
&&
i_has_altivec
!=
0
)
i_capabilities
|=
CPU_CAPABILITY_ALTIVEC
;
# elif defined( CAN_COMPILE_ALTIVEC )
void
(
*
pf_sigill
)
(
int
)
=
signal
(
SIGILL
,
SigHandler
);
i_illegal
=
0
;
i_illegal
=
0
;
if
(
setjmp
(
env
)
==
0
)
if
(
setjmp
(
env
)
==
0
)
...
@@ -277,31 +253,21 @@ uint32_t CPUCapabilities( void )
...
@@ -277,31 +253,21 @@ uint32_t CPUCapabilities( void )
}
}
if
(
i_illegal
==
0
)
if
(
i_illegal
==
0
)
{
i_capabilities
|=
CPU_CAPABILITY_ALTIVEC
;
i_capabilities
|=
CPU_CAPABILITY_ALTIVEC
;
}
signal
(
SIGILL
,
pf_sigill
);
signal
(
SIGILL
,
pf_sigill
);
# else
# else
(
void
)
SigHandler
;
/* Don't complain about dead code here */
(
void
)
SigHandler
;
/* Don't complain about dead code here */
# endif
# endif
return
i_capabilities
;
#elif defined( __sparc__ )
#elif defined( __sparc__ )
i_capabilities
|=
CPU_CAPABILITY_FPU
;
i_capabilities
|=
CPU_CAPABILITY_FPU
;
return
i_capabilities
;
#elif defined( _MSC_VER ) && !defined( UNDER_CE )
#elif defined( _MSC_VER ) && !defined( UNDER_CE )
i_capabilities
|=
CPU_CAPABILITY_FPU
;
i_capabilities
|=
CPU_CAPABILITY_FPU
;
return
i_capabilities
;
#else
/* default behaviour */
return
i_capabilities
;
#endif
#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