source: rtems/testsuites/ada/support/init.c @ fd5471b

Last change on this file since fd5471b was fd5471b, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 1, 2017 at 9:37:06 PM

ada: Check C and POSIX types

Update #3256.

  • Property mode set to 100644
File size: 3.2 KB
Line 
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.h>
14#include <rtems/score/threadimpl.h>
15
16/*
17 * This is the entry point automatically generated by GNAT.
18 */
19extern int gnat_main ( int argc, char **argv, char **envp );
20
21static 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 */
34void ada_test_begin(void);
35void ada_test_end(void);
36uint32_t milliseconds_per_tick(void);
37uint32_t ticks_per_second(void);
38uint32_t work_space_size(void);
39uint32_t is_configured_multiprocessing(void);
40uint32_t get_node(void);
41rtems_id tcb_to_id(Thread_Control *tcb);
42void 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#define CONFIGURE_GNAT_RTEMS
50#define CONFIGURE_MEMORY_OVERHEAD  (256)
51
52#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
53
54#define CONFIGURE_DISABLE_SMP_CONFIGURATION
55
56#include <config.h>
57
58const char rtems_test_name[] = ADA_TEST_NAME;
59
60void ada_test_begin(void)
61{
62  rtems_test_begin(rtems_test_name, RTEMS_TEST_STATE_PASS);
63}
64
65void ada_test_end(void)
66{
67  rtems_test_end(rtems_test_name);
68}
69
70rtems_id tcb_to_id(
71  Thread_Control *tcb
72)
73{
74  return tcb->Object.id; /* Only for sp04 */
75}
76
77uint32_t milliseconds_per_tick(void)
78{
79  return CONFIGURE_MICROSECONDS_PER_TICK / 1000;
80}
81
82uint32_t ticks_per_second(void)
83{
84  return rtems_clock_get_ticks_per_second();
85}
86
87uint32_t work_space_size(void)
88{
89  return rtems_configuration_get_work_space_size()
90    + rtems_configuration_get_stack_space_size();
91}
92
93uint32_t is_configured_multiprocessing(void)
94{
95#if defined(RTEMS_MULTIPROCESSING)
96  return 1;
97#else
98  return 0;
99#endif
100}
101
102uint32_t get_node(void)
103{
104  /* XXX HACK -- use public API */
105  return _Objects_Local_node;
106}
107
108typedef struct {
109  const char *name;
110  long size;
111  long alignment;
112} type_spec;
113
114#define TYPE_SPEC(t) { #t, sizeof(t) * CHAR_BIT, _Alignof(t) }
115
116static const type_spec types[] = {
117  TYPE_SPEC(clockid_t),
118  TYPE_SPEC(pid_t),
119  TYPE_SPEC(pthread_attr_t),
120  TYPE_SPEC(pthread_condattr_t),
121  TYPE_SPEC(pthread_cond_t),
122  TYPE_SPEC(pthread_key_t),
123  TYPE_SPEC(pthread_mutexattr_t),
124  TYPE_SPEC(pthread_mutex_t),
125  TYPE_SPEC(pthread_rwlockattr_t),
126  TYPE_SPEC(pthread_rwlock_t),
127  TYPE_SPEC(pthread_t),
128  TYPE_SPEC(rtems_id),
129  TYPE_SPEC(sigset_t),
130  TYPE_SPEC(stack_t),
131  TYPE_SPEC(struct sched_param),
132  TYPE_SPEC(struct sigaction),
133  TYPE_SPEC(struct timespec)
134};
135
136void check_type(long type, long size, long alignment)
137{
138  if (type >= 0 && type < (long) RTEMS_ARRAY_SIZE(types)) {
139    const type_spec *ts;
140
141    ts = &types[type];
142    printf(
143      "%s: size %li == %li, alignment %li == %li\n",
144      ts->name,
145      ts->size,
146      size,
147      ts->alignment,
148      alignment
149    );
150    if (ts->size != size || ts->alignment != alignment) {
151      exit(0);
152    }
153  } else {
154    exit(0);
155  }
156}
Note: See TracBrowser for help on using the repository browser.