Merge popcount implementation in emucore.h with the new eminline (nw)

This commit is contained in:
AJR 2017-10-24 09:43:07 -04:00
parent 2cbe3d3d4d
commit 0853bb469b
3 changed files with 10 additions and 15 deletions

View File

@ -384,19 +384,6 @@ enum_value(T value) noexcept
// INLINE FUNCTIONS
//**************************************************************************
// population count
#if !defined(__NetBSD__)
inline int popcount(u32 val)
{
int count;
for (count = 0; val != 0; count++)
val &= val - 1;
return count;
}
#endif
// convert a series of 32 bits into a float
inline float u2f(u32 v)
{

View File

@ -271,8 +271,8 @@ READ16_MEMBER(namcona1_state::custom_key_r)
res = BITSWAP16(m_keyval, 22,26,31,23,18,20,16,30,24,21,25,19,17,29,28,27);
m_keyval >>= 1;
// printf("popcount(%08X) = %d\n", m_keyval & 0x58000c00, popcount(m_keyval & 0x58000c00));
if((!m_keyval) || (popcount(m_keyval & 0x58000c00) & 1))
// printf("popcount(%08X) = %d\n", m_keyval & 0x58000c00, population_count_32(m_keyval & 0x58000c00));
if((!m_keyval) || (population_count_32(m_keyval & 0x58000c00) & 1))
m_keyval ^= 0x80000000;
return res;

View File

@ -301,6 +301,9 @@ inline uint8_t count_leading_ones(uint32_t val)
-------------------------------------------------*/
#ifndef population_count_32
#if defined(__NetBSD__)
#define population_count_32 popcount32
#else
inline unsigned population_count_32(uint32_t val)
{
#if defined(__GNUC__)
@ -320,6 +323,7 @@ inline unsigned population_count_32(uint32_t val)
#endif
}
#endif
#endif
/*-------------------------------------------------
@ -328,6 +332,9 @@ inline unsigned population_count_32(uint32_t val)
-------------------------------------------------*/
#ifndef population_count_64
#if defined(__NetBSD__)
#define population_count_64 popcount64
#else
inline unsigned population_count_64(uint64_t val)
{
#if defined(__GNUC__)
@ -356,6 +363,7 @@ inline unsigned population_count_64(uint64_t val)
#endif
}
#endif
#endif
/***************************************************************************