source: rtems/testsuites/psxtmtests/psxtmkey02/init.c

Last change on this file was 842a7dd8, checked in by Joel Sherrill <joel@…>, on 04/08/22 at 14:23:16

psxtmtests/psxtmkey02/init.c: Manually change license to BSD-2

This has yet another typo in the license and was missed by the script.

Updates #3053.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 * POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif
30
31#include <timesys.h>
32#include <rtems/btimer.h>
33#include <errno.h>
34#include <pthread.h>
35#include "test_support.h"
36
37const char rtems_test_name[] = "PSXTMKEY 02";
38
39/* forward declarations to avoid warnings */
40void *POSIX_Init(void *argument);
41void benchmark_pthread_setspecific(void *value_p);
42void benchmark_pthread_getspecific( void *expected );
43
44pthread_key_t Key;
45int           Value1;
46
47void benchmark_pthread_setspecific( void *value_p )
48{
49  benchmark_timer_t end_time;
50  int  status;
51
52  benchmark_timer_initialize();
53    status = pthread_setspecific( Key, value_p );
54  end_time = benchmark_timer_read();
55  rtems_test_assert( status == 0 );
56
57  put_time(
58    "pthread_setspecific: only case: only case",
59    end_time,
60    1,        /* Only executed once */
61    0,
62    0
63  );
64
65}
66
67void benchmark_pthread_getspecific( void *expected )
68{
69  benchmark_timer_t end_time;
70  void *value_p;
71
72  benchmark_timer_initialize();
73    value_p = pthread_getspecific( Key );
74  end_time = benchmark_timer_read();
75  rtems_test_assert( value_p == expected );
76
77  put_time(
78    "pthread_getspecific: only case",
79    end_time,
80    1,        /* Only executed once */
81    0,
82    0
83  );
84}
85
86void *POSIX_Init(
87  void *argument
88)
89{
90  int  status;
91
92  TEST_BEGIN();
93
94  /* create the key */
95  status = pthread_key_create( &Key, NULL );
96  rtems_test_assert( status == 0 );
97
98  benchmark_pthread_getspecific( NULL );
99  benchmark_pthread_setspecific( &Value1 );
100  benchmark_pthread_getspecific( &Value1 );
101
102  /* destroy the key */
103  status = pthread_key_delete( Key );
104  rtems_test_assert( status == 0 );
105
106  TEST_END();
107  rtems_test_exit(0);
108}
109
110/* configuration information */
111
112#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
113#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
114
115#define CONFIGURE_MAXIMUM_POSIX_THREADS  2
116#define CONFIGURE_MAXIMUM_POSIX_KEYS     1
117#define CONFIGURE_POSIX_INIT_THREAD_TABLE
118
119#define CONFIGURE_INIT
120#include <rtems/confdefs.h>
121/* end of file */
Note: See TracBrowser for help on using the repository browser.