1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2015 |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | */ |
---|
5 | |
---|
6 | #include <sys/types.h> |
---|
7 | #include <limits.h> |
---|
8 | #include <pthread.h> |
---|
9 | #include <stdio.h> |
---|
10 | #include <stdlib.h> |
---|
11 | |
---|
12 | #include <rtems.h> |
---|
13 | #include <rtems/test-info.h> |
---|
14 | #include <rtems/score/threadimpl.h> |
---|
15 | |
---|
16 | /* |
---|
17 | * This is the entry point automatically generated by GNAT. |
---|
18 | */ |
---|
19 | extern int gnat_main ( int argc, char **argv, char **envp ); |
---|
20 | |
---|
21 | static void *POSIX_Init( |
---|
22 | void *argument |
---|
23 | ) |
---|
24 | { |
---|
25 | (void) gnat_main ( 0, 0, 0 ); |
---|
26 | |
---|
27 | exit( 0 ); |
---|
28 | } |
---|
29 | |
---|
30 | /* |
---|
31 | * Prototypes for various test support routines. Since these are bound to |
---|
32 | * from Ada, there are no external .h files even though they must be public. |
---|
33 | */ |
---|
34 | void ada_test_begin(void); |
---|
35 | void ada_test_end(void); |
---|
36 | uint32_t milliseconds_per_tick(void); |
---|
37 | uint32_t ticks_per_second(void); |
---|
38 | size_t work_space_size(void); |
---|
39 | uint32_t is_configured_multiprocessing(void); |
---|
40 | uint32_t get_node(void); |
---|
41 | rtems_id tcb_to_id(Thread_Control *tcb); |
---|
42 | void check_type(long type, long size, long alignment); |
---|
43 | |
---|
44 | /* |
---|
45 | * By putting this in brackets rather than quotes, we get the search |
---|
46 | * path and can get this file from ".." in the mptests. |
---|
47 | */ |
---|
48 | #define CONFIGURE_INIT |
---|
49 | |
---|
50 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
51 | |
---|
52 | #include <rtems/confdefs.h> |
---|
53 | |
---|
54 | const char rtems_test_name[] = ADA_TEST_NAME; |
---|
55 | |
---|
56 | void ada_test_begin(void) |
---|
57 | { |
---|
58 | rtems_test_begin(rtems_test_name, RTEMS_TEST_STATE_PASS); |
---|
59 | } |
---|
60 | |
---|
61 | void ada_test_end(void) |
---|
62 | { |
---|
63 | fsync(STDOUT_FILENO); |
---|
64 | rtems_test_end(rtems_test_name); |
---|
65 | } |
---|
66 | |
---|
67 | rtems_id tcb_to_id( |
---|
68 | Thread_Control *tcb |
---|
69 | ) |
---|
70 | { |
---|
71 | return tcb->Object.id; /* Only for sp04 */ |
---|
72 | } |
---|
73 | |
---|
74 | uint32_t milliseconds_per_tick(void) |
---|
75 | { |
---|
76 | return CONFIGURE_MICROSECONDS_PER_TICK / 1000; |
---|
77 | } |
---|
78 | |
---|
79 | uint32_t ticks_per_second(void) |
---|
80 | { |
---|
81 | return rtems_clock_get_ticks_per_second(); |
---|
82 | } |
---|
83 | |
---|
84 | size_t work_space_size(void) |
---|
85 | { |
---|
86 | return rtems_configuration_get_work_space_size() |
---|
87 | + rtems_configuration_get_stack_space_size(); |
---|
88 | } |
---|
89 | |
---|
90 | uint32_t is_configured_multiprocessing(void) |
---|
91 | { |
---|
92 | #if defined(RTEMS_MULTIPROCESSING) |
---|
93 | return 1; |
---|
94 | #else |
---|
95 | return 0; |
---|
96 | #endif |
---|
97 | } |
---|
98 | |
---|
99 | uint32_t get_node(void) |
---|
100 | { |
---|
101 | return rtems_object_get_local_node(); |
---|
102 | } |
---|
103 | |
---|
104 | typedef struct { |
---|
105 | const char *name; |
---|
106 | long size; |
---|
107 | long alignment; |
---|
108 | } type_spec; |
---|
109 | |
---|
110 | #define TYPE_SPEC(t) { #t, sizeof(t) * CHAR_BIT, _Alignof(t) } |
---|
111 | |
---|
112 | static const type_spec types[] = { |
---|
113 | TYPE_SPEC(clockid_t), |
---|
114 | TYPE_SPEC(pid_t), |
---|
115 | TYPE_SPEC(pthread_attr_t), |
---|
116 | TYPE_SPEC(pthread_condattr_t), |
---|
117 | TYPE_SPEC(pthread_cond_t), |
---|
118 | TYPE_SPEC(pthread_key_t), |
---|
119 | TYPE_SPEC(pthread_mutexattr_t), |
---|
120 | TYPE_SPEC(pthread_mutex_t), |
---|
121 | TYPE_SPEC(pthread_rwlockattr_t), |
---|
122 | TYPE_SPEC(pthread_rwlock_t), |
---|
123 | TYPE_SPEC(pthread_t), |
---|
124 | TYPE_SPEC(rtems_id), |
---|
125 | TYPE_SPEC(sigset_t), |
---|
126 | TYPE_SPEC(stack_t), |
---|
127 | TYPE_SPEC(struct sched_param), |
---|
128 | TYPE_SPEC(struct sigaction), |
---|
129 | TYPE_SPEC(struct timespec) |
---|
130 | }; |
---|
131 | |
---|
132 | void check_type(long type, long size, long alignment) |
---|
133 | { |
---|
134 | if (type >= 0 && type < (long) RTEMS_ARRAY_SIZE(types)) { |
---|
135 | const type_spec *ts; |
---|
136 | |
---|
137 | ts = &types[type]; |
---|
138 | printf( |
---|
139 | "%s: size %li == %li, alignment %li == %li\n", |
---|
140 | ts->name, |
---|
141 | ts->size, |
---|
142 | size, |
---|
143 | ts->alignment, |
---|
144 | alignment |
---|
145 | ); |
---|
146 | if (ts->size != size || ts->alignment != alignment) { |
---|
147 | exit(0); |
---|
148 | } |
---|
149 | } else { |
---|
150 | exit(0); |
---|
151 | } |
---|
152 | } |
---|