[43469af] | 1 | /* |
---|
[50162e0] | 2 | * COPYRIGHT (c) 1989-2013. |
---|
[43469af] | 3 | * On-Line Applications Research Corporation (OAR). |
---|
| 4 | * |
---|
| 5 | * The license and distribution terms for this file may be |
---|
| 6 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 7 | * http:www.rtems.org/license/LICENSE. |
---|
[43469af] | 8 | */ |
---|
| 9 | |
---|
| 10 | #ifdef HAVE_CONFIG_H |
---|
| 11 | #include "config.h" |
---|
| 12 | #endif |
---|
| 13 | |
---|
| 14 | #include <timesys.h> |
---|
| 15 | #include <rtems/timerdrv.h> |
---|
| 16 | #include <errno.h> |
---|
| 17 | #include <pthread.h> |
---|
| 18 | #include "test_support.h" |
---|
| 19 | |
---|
[fd46711] | 20 | const char rtems_test_name[] = "PSXTMKEY 02"; |
---|
| 21 | |
---|
[991a3cc1] | 22 | /* forward declarations to avoid warnings */ |
---|
| 23 | void *POSIX_Init(void *argument); |
---|
| 24 | void benchmark_pthread_setspecific(void *value_p); |
---|
| 25 | void benchmark_pthread_getspecific( void *expected ); |
---|
| 26 | |
---|
[43469af] | 27 | pthread_key_t Key; |
---|
| 28 | int Value1; |
---|
| 29 | |
---|
| 30 | void benchmark_pthread_setspecific( void *value_p ) |
---|
| 31 | { |
---|
[add2977] | 32 | benchmark_timer_t end_time; |
---|
[43469af] | 33 | int status; |
---|
| 34 | |
---|
| 35 | benchmark_timer_initialize(); |
---|
| 36 | status = pthread_setspecific( Key, value_p ); |
---|
| 37 | end_time = benchmark_timer_read(); |
---|
| 38 | rtems_test_assert( status == 0 ); |
---|
| 39 | |
---|
| 40 | put_time( |
---|
[50162e0] | 41 | "pthread_setspecific: only case: only case", |
---|
[43469af] | 42 | end_time, |
---|
| 43 | 1, /* Only executed once */ |
---|
| 44 | 0, |
---|
| 45 | 0 |
---|
| 46 | ); |
---|
| 47 | |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | void benchmark_pthread_getspecific( void *expected ) |
---|
| 51 | { |
---|
[add2977] | 52 | benchmark_timer_t end_time; |
---|
[43469af] | 53 | void *value_p; |
---|
| 54 | |
---|
| 55 | benchmark_timer_initialize(); |
---|
| 56 | value_p = pthread_getspecific( Key ); |
---|
| 57 | end_time = benchmark_timer_read(); |
---|
| 58 | rtems_test_assert( value_p == expected ); |
---|
| 59 | |
---|
| 60 | put_time( |
---|
[50162e0] | 61 | "pthread_getspecific: only case", |
---|
[43469af] | 62 | end_time, |
---|
| 63 | 1, /* Only executed once */ |
---|
| 64 | 0, |
---|
| 65 | 0 |
---|
| 66 | ); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | void *POSIX_Init( |
---|
| 70 | void *argument |
---|
| 71 | ) |
---|
| 72 | { |
---|
| 73 | int status; |
---|
| 74 | |
---|
[fd46711] | 75 | TEST_BEGIN(); |
---|
[43469af] | 76 | |
---|
| 77 | /* create the key */ |
---|
| 78 | status = pthread_key_create( &Key, NULL ); |
---|
| 79 | rtems_test_assert( status == 0 ); |
---|
| 80 | |
---|
| 81 | benchmark_pthread_getspecific( NULL ); |
---|
| 82 | benchmark_pthread_setspecific( &Value1 ); |
---|
| 83 | benchmark_pthread_getspecific( &Value1 ); |
---|
| 84 | |
---|
| 85 | /* destroy the key */ |
---|
| 86 | status = pthread_key_delete( Key ); |
---|
| 87 | rtems_test_assert( status == 0 ); |
---|
| 88 | |
---|
[fd46711] | 89 | TEST_END(); |
---|
[43469af] | 90 | rtems_test_exit(0); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | /* configuration information */ |
---|
| 94 | |
---|
| 95 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 96 | #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER |
---|
| 97 | |
---|
| 98 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 2 |
---|
| 99 | #define CONFIGURE_MAXIMUM_POSIX_KEYS 1 |
---|
| 100 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
| 101 | |
---|
| 102 | #define CONFIGURE_INIT |
---|
| 103 | #include <rtems/confdefs.h> |
---|
| 104 | /* end of file */ |
---|