termux-packages/packages/bison/ffsl.h.patch

51 lines
1.7 KiB
Diff

--- ../ffsl.h.orig 2021-11-09 21:28:29.347410128 +0100
+++ ./lib/ffsl.h 2021-11-09 21:28:50.760733519 +0100
@@ -46,47 +46,3 @@
#if !defined FUNC || !defined TYPE
# error
#endif
-
-int
-FUNC (TYPE i)
-{
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) \
- || (__clang_major__ >= 4)
- return GCC_BUILTIN (i);
-#elif defined _MSC_VER && defined MSVC_BUILTIN
- /* _BitScanForward, _BitScanForward64
- <https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64> */
- unsigned long bit;
- if (MSVC_BUILTIN (&bit, i))
- return bit + 1;
- else
- return 0;
-#else
- unsigned TYPE j = i;
- /* Split j into chunks, and look at one chunk after the other. */
- enum { chunk_bits = CHAR_BIT * sizeof (unsigned int) };
- /* The number of chunks is ceil (sizeof (TYPE) / sizeof (unsigned int))
- = (sizeof (TYPE) - 1) / sizeof (unsigned int) + 1. */
- enum { chunk_count = (sizeof (TYPE) - 1) / sizeof (unsigned int) + 1 };
-
- if (chunk_count > 1)
- {
- size_t k;
-
- /* It is tempting to write if (!j) here, but if we do this,
- Solaris 10/x86 "cc -O" miscompiles the code. */
- if (!i)
- return 0;
- /* Unroll the first loop round. k = 0. */
- if ((unsigned int) j)
- return ffs ((unsigned int) j);
- /* Generic loop. */
- for (k = 1; k < chunk_count - 1; k++)
- if ((unsigned int) (j >> (k * chunk_bits)) != 0)
- return k * chunk_bits + ffs ((unsigned int) (j >> (k * chunk_bits)));
- }
- /* Last loop round. k = chunk_count - 1. */
- return (chunk_count - 1) * chunk_bits
- + ffs ((unsigned int) (j >> ((chunk_count - 1) * chunk_bits)));
-#endif
-}