[PATCH i-g-t 4/4] tests/sw_sync: use __atomic_* instead of __sync_*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace calls to the older __sync_* functions with the new __atomic_*
standard ones to be consistent with other tests and improve
portability across CPU architectures.

Signed-off-by: Guillaume Tucker <guillaume.tucker@xxxxxxxxxxxxx>
---
 tests/Makefile.am | 1 +
 tests/sw_sync.c   | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 18a0f1f20592..71514d4d2e5a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -121,6 +121,7 @@ prime_self_import_LDADD = $(LDADD) -lpthread
 gem_userptr_blits_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_userptr_blits_LDADD = $(LDADD) -lpthread
 perf_pmu_LDADD = $(LDADD) $(top_builddir)/lib/libigt_perf.la
+sw_sync_LDADD = $(LDADD) -latomic
 
 kms_flip_LDADD = $(LDADD) -lpthread
 
diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 950b8b614759..2ee1e1c60b32 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -517,7 +517,7 @@ static void test_sync_multi_consumer(void)
 	{
 		sem_wait(&sem);
 
-		__sync_fetch_and_add(&counter, 1);
+		__atomic_fetch_add(&counter, 1, __ATOMIC_SEQ_CST);
 		sw_sync_timeline_inc(timeline, 1);
 	}
 
@@ -554,7 +554,8 @@ static void * test_sync_multi_consumer_producer_thread(void *arg)
 		if (sync_fence_wait(fence, 1000) < 0)
 			return (void *) 1;
 
-		if (__sync_fetch_and_add(data->counter, 1) != next_point)
+		if (__atomic_fetch_add(data->counter, 1, __ATOMIC_SEQ_CST) !=
+		    next_point)
 			return (void *) 1;
 
 		/* Kick off the next thread. */
@@ -900,4 +901,3 @@ igt_main
 	igt_subtest("sync_random_merge")
 		test_sync_random_merge();
 }
-
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux