Commit fa2c1e54 authored by Sam Hocevar's avatar Sam Hocevar

* Do not assume anything about sizeof(cpu_set_t).


git-svn-id: svn://svn.videolan.org/x264/trunk@606 df754926-b1dd-0310-bc7b-ec298dee348c
parent 167abec1
......@@ -163,16 +163,18 @@ int x264_cpu_num_processors( void )
return 1;
#elif defined(SYS_LINUX) || defined(WIN32)
unsigned int bit;
int np;
#if defined(WIN32)
uint32_t p_aff, s_aff;
GetProcessAffinityMask( GetCurrentProcess(), &p_aff, &s_aff );
#else
uint64_t p_aff;
sched_getaffinity( 0, sizeof(p_aff), (cpu_set_t*)&p_aff );
cpu_set_t p_aff;
memset( &p_aff, 0, sizeof(p_aff) );
sched_getaffinity( 0, sizeof(p_aff), &p_aff );
#endif
for( np = 0; p_aff != 0; p_aff >>= 1 )
np += p_aff&1;
for( np = 0, bit = 0; bit < sizeof(p_aff); bit++ )
np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1;
return np;
#elif defined(SYS_BEOS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment