[Mesa-dev] [PATCH] uti/u_atomic: Don't test p_atomic_add with booleans.
Roland Scheidegger
sroland at vmware.com
Fri Feb 13 07:28:16 PST 2015
Looks good to me.
Roland
Am 13.02.2015 um 10:47 schrieb Jose Fonseca:
> Add another class of tests.
>
> Fixes https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D89112&d=AwIBAg&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=Vjtt0vs_iqoI31UfJxBl7yv9I2FeiaeAYgMTLKRBc_I&m=SRFkW8aI4F6SvMOX85Ox9L3paWrP8MTUsPaaHDpNUCk&s=eS-Zs3Ed6akzLy2jjWNkCZrN0yPx-LoQv9nGDCUVt7U&e=
>
> I failed to spot this in my previous change, because bool was a typedef
> for char on the system I tested.
> ---
> src/util/u_atomic_test.c | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/src/util/u_atomic_test.c b/src/util/u_atomic_test.c
> index 8bddf8d..ffe4703 100644
> --- a/src/util/u_atomic_test.c
> +++ b/src/util/u_atomic_test.c
> @@ -37,9 +37,9 @@
> #include "u_atomic.h"
>
>
> -/* Test operations that are supported for all types, including 8 bits types */
> -#define test_atomic_8bits(type, ones) \
> - static void test_atomic_8bits_##type (void) { \
> +/* Test only assignment-like operations, which can be supported on all types */
> +#define test_atomic_assign(type, ones) \
> + static void test_atomic_assign_##type (void) { \
> type v, r; \
> \
> p_atomic_set(&v, ones); \
> @@ -56,6 +56,19 @@
> assert(v == 0 && "p_atomic_cmpxchg"); \
> assert(r == ones && "p_atomic_cmpxchg"); \
> \
> + (void) r; \
> + }
> +
> +
> +/* Test arithmetic operations that are supported on 8bit integer types */
> +#define test_atomic_8bits(type, ones) \
> + test_atomic_assign(type, ones) \
> + \
> + static void test_atomic_8bits_##type (void) { \
> + type v, r; \
> + \
> + test_atomic_assign_##type(); \
> + \
> v = 23; \
> p_atomic_add(&v, 42); \
> r = p_atomic_read(&v); \
> @@ -65,7 +78,7 @@
> }
>
>
> -/* Test operations that are not supported for 8 bits types */
> +/* Test all operations */
> #define test_atomic(type, ones) \
> test_atomic_8bits(type, ones) \
> \
> @@ -121,7 +134,7 @@ test_atomic(uint64_t, UINT64_C(0xffffffffffffffff))
>
> test_atomic_8bits(int8_t, INT8_C(-1))
> test_atomic_8bits(uint8_t, UINT8_C(0xff))
> -test_atomic_8bits(bool, true)
> +test_atomic_assign(bool, true)
>
> int
> main()
> @@ -138,7 +151,7 @@ main()
>
> test_atomic_8bits_int8_t();
> test_atomic_8bits_uint8_t();
> - test_atomic_8bits_bool();
> + test_atomic_assign_bool();
>
> return 0;
> }
>
More information about the mesa-dev
mailing list