[mutter] cogl: Make various functions non-optional
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cogl: Make various functions non-optional
- Date: Tue, 6 Nov 2018 18:04:13 +0000 (UTC)
commit 46942c24a3c2f72c75bc233b2a9b825bdd3bde7b
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Thu May 3 20:34:51 2018 +0200
cogl: Make various functions non-optional
Remove fallback implementations of some functions available in
gcc/clang and Linux/BSDs.
cogl/cogl-mutter-config.h.in | 6 ----
cogl/cogl/cogl-util.c | 86 --------------------------------------------
cogl/cogl/cogl-util.h | 66 ----------------------------------
3 files changed, 158 deletions(-)
---
diff --git a/cogl/cogl-mutter-config.h.in b/cogl/cogl-mutter-config.h.in
index 83e3a9eda..cce8e6512 100644
--- a/cogl/cogl-mutter-config.h.in
+++ b/cogl/cogl-mutter-config.h.in
@@ -6,9 +6,3 @@
/* Have GLES 2.0 for rendering */
#undef HAVE_COGL_GLES2
-
-/* Define to 1 if you have the `ffs' function. */
-#undef HAVE_FFS
-
-/* Define to 1 if you have the `memmem' function. */
-#undef HAVE_MEMMEM
diff --git a/cogl/cogl/cogl-util.c b/cogl/cogl/cogl-util.c
index f26c8961a..c4cdb57f7 100644
--- a/cogl/cogl/cogl-util.c
+++ b/cogl/cogl/cogl-util.c
@@ -67,70 +67,6 @@ _cogl_util_one_at_a_time_mix (unsigned int hash)
return hash;
}
-/* The 'ffs' function is part of C99 so it isn't always available */
-#ifndef HAVE_FFS
-
-int
-_cogl_util_ffs (int num)
-{
- int i = 1;
-
- if (num == 0)
- return 0;
-
- while ((num & 1) == 0)
- {
- num >>= 1;
- i++;
- }
-
- return i;
-}
-#endif /* HAVE_FFS */
-
-/* The 'ffsl' is non-standard but when building with GCC we'll use its
- builtin instead */
-#ifndef COGL_UTIL_HAVE_BUILTIN_FFSL
-
-int
-_cogl_util_ffsl_wrapper (long int num)
-{
- int i = 1;
-
- if (num == 0)
- return 0;
-
- while ((num & 1) == 0)
- {
- num >>= 1;
- i++;
- }
-
- return i;
-}
-
-#endif /* COGL_UTIL_HAVE_BUILTIN_FFSL */
-
-#ifndef COGL_UTIL_HAVE_BUILTIN_POPCOUNTL
-
-const unsigned char
-_cogl_util_popcount_table[256] =
- {
- 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4,
- 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4,
- 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
- 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5,
- 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
- 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
- };
-
-#endif /* COGL_UTIL_HAVE_BUILTIN_POPCOUNTL */
-
/* tests/conform/test-bitmask.c tests some cogl internals and includes this
* file directly but since these functions depend on other internal Cogl
* symbols we hide them from test-bitmask.c
@@ -261,26 +197,4 @@ _cogl_util_pixel_format_from_masks (unsigned long r_mask,
return image_format;
}
-#ifndef HAVE_MEMMEM
-
-char *
-_cogl_util_memmem (const void *haystack,
- size_t haystack_len,
- const void *needle,
- size_t needle_len)
-{
- size_t i;
-
- if (needle_len > haystack_len)
- return NULL;
-
- for (i = 0; i <= haystack_len - needle_len; i++)
- if (!memcmp ((const char *) haystack + i, needle, needle_len))
- return (char *) haystack + i;
-
- return NULL;
-}
-
-#endif /* HAVE_MEMMEM */
-
#endif /* _COGL_IN_TEST_BITMASK */
diff --git a/cogl/cogl/cogl-util.h b/cogl/cogl/cogl-util.h
index a821e55c4..70259d387 100644
--- a/cogl/cogl/cogl-util.h
+++ b/cogl/cogl/cogl-util.h
@@ -114,75 +114,17 @@ _cogl_util_one_at_a_time_hash (unsigned int hash,
unsigned int
_cogl_util_one_at_a_time_mix (unsigned int hash);
-/* These two builtins are available since GCC 3.4 */
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-#define COGL_UTIL_HAVE_BUILTIN_FFSL
-#define COGL_UTIL_HAVE_BUILTIN_POPCOUNTL
-#define COGL_UTIL_HAVE_BUILTIN_CLZ
-#endif
-/* The 'ffs' function is part of C99 so it isn't always available */
-#ifdef HAVE_FFS
#define _cogl_util_ffs ffs
-#else
-int
-_cogl_util_ffs (int num);
-#endif
-
-/* The 'ffsl' function is non-standard but GCC has a builtin for it
- since 3.4 which we can use */
-#ifdef COGL_UTIL_HAVE_BUILTIN_FFSL
#define _cogl_util_ffsl __builtin_ffsl
-#else
-/* If ints and longs are the same size we can just use ffs. Hopefully
- the compiler will optimise away this conditional */
-#define _cogl_util_ffsl(x) \
- (sizeof (long int) == sizeof (int) ? _cogl_util_ffs ((int) x) : \
- _cogl_util_ffsl_wrapper (x))
-int
-_cogl_util_ffsl_wrapper (long int num);
-#endif /* COGL_UTIL_HAVE_BUILTIN_FFSL */
static inline unsigned int
_cogl_util_fls (unsigned int n)
{
-#ifdef COGL_UTIL_HAVE_BUILTIN_CLZ
return n == 0 ? 0 : sizeof (unsigned int) * 8 - __builtin_clz (n);
-#else
- unsigned int v = 1;
-
- if (n == 0)
- return 0;
-
- while (n >>= 1)
- v++;
-
- return v;
-#endif
}
-#ifdef COGL_UTIL_HAVE_BUILTIN_POPCOUNTL
#define _cogl_util_popcountl __builtin_popcountl
-#else
-extern const unsigned char _cogl_util_popcount_table[256];
-
-/* There are many ways of doing popcount but doing a table lookup
- seems to be the most robust against different sizes for long. Some
- pages seem to claim it's the fastest method anyway. */
-static inline int
-_cogl_util_popcountl (unsigned long num)
-{
- int i;
- int sum = 0;
-
- /* Let's hope GCC will unroll this loop.. */
- for (i = 0; i < sizeof (num); i++)
- sum += _cogl_util_popcount_table[(num >> (i * 8)) & 0xff];
-
- return sum;
-}
-
-#endif /* COGL_UTIL_HAVE_BUILTIN_POPCOUNTL */
#define _COGL_RETURN_IF_FAIL(EXPR) g_return_if_fail(EXPR)
#define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) g_return_val_if_fail(EXPR, VAL)
@@ -222,15 +164,7 @@ _cogl_util_pixel_format_from_masks (unsigned long r_mask,
#define _COGL_STATIC_ASSERT(EXPRESSION, MESSAGE) \
_Static_assert (EXPRESSION, MESSAGE);
-#ifdef HAVE_MEMMEM
#define _cogl_util_memmem memmem
-#else
-char *
-_cogl_util_memmem (const void *haystack,
- size_t haystack_len,
- const void *needle,
- size_t needle_len);
-#endif
static inline void
_cogl_util_scissor_intersect (int rect_x0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]