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
806505a4
Commit
806505a4
authored
Aug 25, 2011
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_CPU_init: factorize altivec check by using asm input
also simplify arm neon preprocessor checks
parent
e155b93a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
38 deletions
+25
-38
src/misc/cpu.c
src/misc/cpu.c
+25
-38
No files found.
src/misc/cpu.c
View file @
806505a4
...
@@ -73,13 +73,13 @@ static bool check_OS_capability( const char *psz_capability, pid_t pid )
...
@@ -73,13 +73,13 @@ static bool check_OS_capability( const char *psz_capability, pid_t pid )
return
false
;
return
false
;
}
}
# define check_capability(name, flag, code
)
\
# define check_capability(name, flag, code
, input)
\
do { \
do { \
pid_t pid = fork(); \
pid_t pid = fork(); \
if( pid == 0 ) \
if( pid == 0 ) \
{ \
{ \
signal(SIGILL, SIG_DFL); \
signal(SIGILL, SIG_DFL); \
__asm__ __volatile__ ( code : :
);
\
__asm__ __volatile__ ( code : :
input );
\
_exit(0); \
_exit(0); \
} \
} \
if( check_OS_capability((name), pid )) \
if( check_OS_capability((name), pid )) \
...
@@ -87,7 +87,7 @@ static bool check_OS_capability( const char *psz_capability, pid_t pid )
...
@@ -87,7 +87,7 @@ static bool check_OS_capability( const char *psz_capability, pid_t pid )
} while(0)
} while(0)
# else
/* WIN32 */
# else
/* WIN32 */
# define check_capability(name, flag, code) \
# define check_capability(name, flag, code
, input
) \
i_capabilities |= (flag);
i_capabilities |= (flag);
# endif
# endif
#endif
#endif
...
@@ -184,7 +184,7 @@ void vlc_CPU_init (void)
...
@@ -184,7 +184,7 @@ void vlc_CPU_init (void)
# ifdef CAN_COMPILE_SSE
# ifdef CAN_COMPILE_SSE
check_capability
(
"SSE"
,
CPU_CAPABILITY_SSE
,
check_capability
(
"SSE"
,
CPU_CAPABILITY_SSE
,
"xorps %%xmm0,%%xmm0
\n
"
);
"xorps %%xmm0,%%xmm0
\n
"
,
);
# endif
# endif
}
}
# endif
# endif
...
@@ -194,7 +194,7 @@ void vlc_CPU_init (void)
...
@@ -194,7 +194,7 @@ void vlc_CPU_init (void)
# elif defined (CAN_COMPILE_SSE2)
# elif defined (CAN_COMPILE_SSE2)
if
(
i_edx
&
0x04000000
)
if
(
i_edx
&
0x04000000
)
check_capability
(
"SSE2"
,
CPU_CAPABILITY_SSE2
,
check_capability
(
"SSE2"
,
CPU_CAPABILITY_SSE2
,
"movupd %%xmm0, %%xmm0
\n
"
);
"movupd %%xmm0, %%xmm0
\n
"
,
);
# endif
# endif
# if defined (__SSE3__)
# if defined (__SSE3__)
...
@@ -202,7 +202,7 @@ void vlc_CPU_init (void)
...
@@ -202,7 +202,7 @@ void vlc_CPU_init (void)
# elif defined (CAN_COMPILE_SSE3)
# elif defined (CAN_COMPILE_SSE3)
if
(
i_ecx
&
0x00000001
)
if
(
i_ecx
&
0x00000001
)
check_capability
(
"SSE3"
,
CPU_CAPABILITY_SSE3
,
check_capability
(
"SSE3"
,
CPU_CAPABILITY_SSE3
,
"movsldup %%xmm1, %%xmm0
\n
"
);
"movsldup %%xmm1, %%xmm0
\n
"
,
);
# endif
# endif
# if defined (__SSSE3__)
# if defined (__SSSE3__)
...
@@ -210,7 +210,7 @@ void vlc_CPU_init (void)
...
@@ -210,7 +210,7 @@ void vlc_CPU_init (void)
# elif defined (CAN_COMPILE_SSSE3)
# elif defined (CAN_COMPILE_SSSE3)
if
(
i_ecx
&
0x00000200
)
if
(
i_ecx
&
0x00000200
)
check_capability
(
"SSSE3"
,
CPU_CAPABILITY_SSSE3
,
check_capability
(
"SSSE3"
,
CPU_CAPABILITY_SSSE3
,
"pabsw %%xmm1, %%xmm0
\n
"
);
"pabsw %%xmm1, %%xmm0
\n
"
,
);
# endif
# endif
# if defined (__SSE4_1__)
# if defined (__SSE4_1__)
...
@@ -218,7 +218,7 @@ void vlc_CPU_init (void)
...
@@ -218,7 +218,7 @@ void vlc_CPU_init (void)
# elif defined (CAN_COMPILE_SSE4_1)
# elif defined (CAN_COMPILE_SSE4_1)
if
(
i_ecx
&
0x00080000
)
if
(
i_ecx
&
0x00080000
)
check_capability
(
"SSE4.1"
,
CPU_CAPABILITY_SSE4_1
,
check_capability
(
"SSE4.1"
,
CPU_CAPABILITY_SSE4_1
,
"pmaxsb %%xmm1, %%xmm0
\n
"
);
"pmaxsb %%xmm1, %%xmm0
\n
"
,
);
# endif
# endif
# if defined (__SSE4_2__)
# if defined (__SSE4_2__)
...
@@ -226,7 +226,7 @@ void vlc_CPU_init (void)
...
@@ -226,7 +226,7 @@ void vlc_CPU_init (void)
# elif defined (CAN_COMPILE_SSE4_2)
# elif defined (CAN_COMPILE_SSE4_2)
if
(
i_ecx
&
0x00100000
)
if
(
i_ecx
&
0x00100000
)
check_capability
(
"SSE4.2"
,
CPU_CAPABILITY_SSE4_2
,
check_capability
(
"SSE4.2"
,
CPU_CAPABILITY_SSE4_2
,
"pcmpgtq %%xmm1, %%xmm0
\n
"
);
"pcmpgtq %%xmm1, %%xmm0
\n
"
,
);
# endif
# endif
/* test for additional capabilities */
/* test for additional capabilities */
...
@@ -243,7 +243,7 @@ void vlc_CPU_init (void)
...
@@ -243,7 +243,7 @@ void vlc_CPU_init (void)
# elif defined (CAN_COMPILE_3DNOW)
# elif defined (CAN_COMPILE_3DNOW)
if
(
i_edx
&
0x80000000
)
if
(
i_edx
&
0x80000000
)
check_capability
(
"3D Now!"
,
CPU_CAPABILITY_3DNOW
,
check_capability
(
"3D Now!"
,
CPU_CAPABILITY_3DNOW
,
"pfadd %%mm0,%%mm0
\n
"
"femms
\n
"
);
"pfadd %%mm0,%%mm0
\n
"
"femms
\n
"
,
);
# endif
# endif
if
(
b_amd
&&
(
i_edx
&
0x00400000
)
)
if
(
b_amd
&&
(
i_edx
&
0x00400000
)
)
...
@@ -257,10 +257,6 @@ out:
...
@@ -257,10 +257,6 @@ out:
# if defined (__ARM_NEON__)
# if defined (__ARM_NEON__)
i_capabilities
|=
CPU_CAPABILITY_NEON
;
i_capabilities
|=
CPU_CAPABILITY_NEON
;
# elif defined (CAN_COMPILE_NEON)
# elif defined (CAN_COMPILE_NEON)
# define NEED_RUNTIME_CPU_CHECK 1
# endif
# ifdef NEED_RUNTIME_CPU_CHECK
# if defined (__linux__)
# if defined (__linux__)
FILE
*
info
=
fopen
(
"/proc/cpuinfo"
,
"rt"
);
FILE
*
info
=
fopen
(
"/proc/cpuinfo"
,
"rt"
);
if
(
info
!=
NULL
)
if
(
info
!=
NULL
)
...
@@ -274,11 +270,11 @@ out:
...
@@ -274,11 +270,11 @@ out:
if
(
strncmp
(
line
,
"Features
\t
:"
,
10
))
if
(
strncmp
(
line
,
"Features
\t
:"
,
10
))
continue
;
continue
;
# if defined (CAN_COMPILE_NEON) && !defined (__ARM_NEON__)
cap
=
strstr
(
line
+
10
,
" neon"
);
cap
=
strstr
(
line
+
10
,
" neon"
);
if
(
cap
!=
NULL
&&
(
cap
[
5
]
==
'\0'
||
cap
[
5
]
==
' '
))
if
(
cap
!=
NULL
&&
(
cap
[
5
]
==
'\0'
||
cap
[
5
]
==
' '
))
i_capabilities
|=
CPU_CAPABILITY_NEON
;
i_capabilities
|=
CPU_CAPABILITY_NEON
;
# endif
break
;
break
;
}
}
fclose
(
info
);
fclose
(
info
);
...
@@ -306,19 +302,10 @@ out:
...
@@ -306,19 +302,10 @@ out:
i_capabilities
|=
CPU_CAPABILITY_ALTIVEC
;
i_capabilities
|=
CPU_CAPABILITY_ALTIVEC
;
# elif defined( CAN_COMPILE_ALTIVEC )
# elif defined( CAN_COMPILE_ALTIVEC )
pid_t
pid
=
fork
();
check_capability
(
"Altivec"
,
CPU_CAPABILITY_ALTIVEC
,
if
(
pid
==
0
)
"mtspr 256, %0
\n\t
"
{
"vand %%v0, %%v0, %%v0"
,
signal
(
SIGILL
,
SIG_DFL
);
"r"
(
-
1
));
asm
volatile
(
"mtspr 256, %0
\n\t
"
"vand %%v0, %%v0, %%v0"
:
:
"r"
(
-
1
));
_exit
(
0
);
}
if
(
check_OS_capability
(
"Altivec"
,
pid
)
)
i_capabilities
|=
CPU_CAPABILITY_ALTIVEC
;
# endif
# endif
...
...
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