mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-09 05:10:05 +02:00
ffmpeg7: add implementation of __popcountsi2
from gcc/libgcc/libgcc2.c
This commit is contained in:
committed by
Jérôme Duval
parent
167a24b9fa
commit
033b45f5e2
@@ -402,3 +402,25 @@ __ctzdi2 (UDWtype x)
|
||||
count_trailing_zeros (ret, word);
|
||||
return ret + add;
|
||||
}
|
||||
|
||||
#define POPCOUNTCST2(x) (((UWtype) x << __CHAR_BIT__) | x)
|
||||
#define POPCOUNTCST4(x) (((UWtype) x << (2 * __CHAR_BIT__)) | x)
|
||||
#define POPCOUNTCST8(x) (((UWtype) x << (4 * __CHAR_BIT__)) | x)
|
||||
#if W_TYPE_SIZE == __CHAR_BIT__
|
||||
#define POPCOUNTCST(x) x
|
||||
#elif W_TYPE_SIZE == 2 * __CHAR_BIT__
|
||||
#define POPCOUNTCST(x) POPCOUNTCST2 (x)
|
||||
#elif W_TYPE_SIZE == 4 * __CHAR_BIT__
|
||||
#define POPCOUNTCST(x) POPCOUNTCST4 (POPCOUNTCST2 (x))
|
||||
#elif W_TYPE_SIZE == 8 * __CHAR_BIT__
|
||||
#define POPCOUNTCST(x) POPCOUNTCST8 (POPCOUNTCST4 (POPCOUNTCST2 (x)))
|
||||
#endif
|
||||
|
||||
int
|
||||
__popcountsi2 (UWtype x)
|
||||
{
|
||||
x = x - ((x >> 1) & POPCOUNTCST (0x55));
|
||||
x = (x & POPCOUNTCST (0x33)) + ((x >> 2) & POPCOUNTCST (0x33));
|
||||
x = (x + (x >> 4)) & POPCOUNTCST (0x0F);
|
||||
return (x * POPCOUNTCST (0x01)) >> (W_TYPE_SIZE - __CHAR_BIT__);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ BUILD()
|
||||
cc="gcc${gccSuffix/_/-}"
|
||||
ccArgs="--cc=$cc --cxx=g++${secondaryArchSuffix/_/-}
|
||||
--ld=gcc${secondaryArchSuffix/_/-}
|
||||
--host-ld=gcc${secondaryArchSuffix/_/-} --extra-cflags=-fno-builtin-popcount"
|
||||
--host-ld=gcc${secondaryArchSuffix/_/-}"
|
||||
|
||||
# Hack up base headers to make them think we're on GCC2 ABI
|
||||
mkdir -p include_hacks include_hacks/os include_hacks/config
|
||||
|
||||
Reference in New Issue
Block a user