From cb935426127415d71b3d56bcb2b8d61e42480dd7 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Fri, 4 Mar 2016 13:58:35 +0530 Subject: [PATCH] Use libisc thread functions (cherry picked from commit 051197362ba480595c075c95b20e160b980a05c7) --- lib/dns/tests/name_test.c | 17 ++++++----------- lib/dns/tests/rbt_test.c | 17 ++++++----------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/lib/dns/tests/name_test.c b/lib/dns/tests/name_test.c index efed92073b..32c438eaa2 100644 --- a/lib/dns/tests/name_test.c +++ b/lib/dns/tests/name_test.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -177,7 +178,7 @@ ATF_TC_BODY(benchmark, tc) { isc_time_t ts1, ts2; double t; unsigned int nthreads; - pthread_t threads[32]; + isc_thread_t threads[32]; UNUSED(tc); @@ -192,19 +193,13 @@ ATF_TC_BODY(benchmark, tc) { nthreads = ISC_MIN(isc_os_ncpus(), 32); nthreads = ISC_MAX(nthreads, 1); for (i = 0; i < nthreads; i++) { - int s; - - s = pthread_create(&threads[i], NULL, fromwire_thread, NULL); - - ATF_REQUIRE(s == 0); + result = isc_thread_create(fromwire_thread, NULL, &threads[i]); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); } for (i = 0; i < nthreads; i++) { - int s; - - s = pthread_join(threads[i], NULL); - - ATF_REQUIRE(s == 0); + result = isc_thread_join(threads[i], NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); } result = isc_time_now(&ts2); diff --git a/lib/dns/tests/rbt_test.c b/lib/dns/tests/rbt_test.c index 4d0ca09757..aa100e0edf 100644 --- a/lib/dns/tests/rbt_test.c +++ b/lib/dns/tests/rbt_test.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -1364,7 +1365,7 @@ ATF_TC_BODY(benchmark, tc) { isc_time_t ts1, ts2; double t; unsigned int nthreads; - pthread_t threads[32]; + isc_thread_t threads[32]; UNUSED(tc); @@ -1407,19 +1408,13 @@ ATF_TC_BODY(benchmark, tc) { nthreads = ISC_MIN(isc_os_ncpus(), 32); nthreads = ISC_MAX(nthreads, 1); for (i = 0; i < nthreads; i++) { - int s; - - s = pthread_create(&threads[i], NULL, find_thread, mytree); - - ATF_REQUIRE(s == 0); + result = isc_thread_create(find_thread, mytree, &threads[i]); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); } for (i = 0; i < nthreads; i++) { - int s; - - s = pthread_join(threads[i], NULL); - - ATF_REQUIRE(s == 0); + result = isc_thread_join(threads[i], NULL); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); } result = isc_time_now(&ts2);