From 58f1c192c2aa58d959ecb69197b2650b27f2eb7d Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Thu, 3 Jun 2010 22:03:27 +0200 Subject: can pass thread data now (Linux), adapted tests --- tests/threads/test_counter_mutex.c | 2 +- tests/threads/test_create_join.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/threads/test_counter_mutex.c b/tests/threads/test_counter_mutex.c index af28f6f..b827d15 100644 --- a/tests/threads/test_counter_mutex.c +++ b/tests/threads/test_counter_mutex.c @@ -72,7 +72,7 @@ int main( void ) { for( j = 0; j < NOF_LOOPS; j++ ) { for( i = 0; i < NOF_THREADS; i++ ) { - error = wolf_thread_create( &thread[i], thread_func ); + error = wolf_thread_create( &thread[i], thread_func, NULL ); if( error != WOLF_OK ) { fprintf( stderr, "Unable to start thread %d: %d\n", i, error ); return EXIT_FAILURE; diff --git a/tests/threads/test_create_join.c b/tests/threads/test_create_join.c index 12b39d3..0eaa6a6 100644 --- a/tests/threads/test_create_join.c +++ b/tests/threads/test_create_join.c @@ -25,14 +25,19 @@ #define NOF_ITERATIONS 10000 static WOLF_THREAD_RETURN_DECL thread_func( void *thread_data ) { + int thread_id = *((int *)thread_data); int i; + printf( "Starting thread %d\n", thread_id ); + fflush( stdout ); + for( i = 0; i < NOF_ITERATIONS; i++ ) { printf( "%d\n", i ); fflush( stdout ); } - WOLF_UNUSED( thread_data ); + printf( "Terminating thread %d\n", thread_id ); + fflush( stdout ); WOLF_THREAD_RETURN } @@ -41,9 +46,11 @@ int main( void ) { int i; wolf_thread_t thread[NOF_THREADS]; wolf_error_t error; + int thread_data[NOF_THREADS]; for( i = 0; i < NOF_THREADS; i++ ) { - error = wolf_thread_create( &thread[i], thread_func ); + thread_data[i] = i; + error = wolf_thread_create( &thread[i], thread_func, (void *)&thread_data[i] ); if( error != WOLF_OK ) { fprintf( stderr, "Unable to start thread %d: %d\n", i, error ); return EXIT_FAILURE; -- cgit v1.2.3-54-g00ecf