source: rtems/testsuites/ada/support/init.c @ 337a186

5
Last change on this file since 337a186 was 337a186, checked in by Sebastian Huber <sebastian.huber@…>, on Feb 21, 2018 at 11:40:18 AM

Add a simple task console driver

Close #3320.

  • 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);
38size_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  fsync(STDOUT_FILENO);
68  rtems_test_end(rtems_test_name);
69}
70
71rtems_id tcb_to_id(
72  Thread_Control *tcb
73)
74{
75  return tcb->Object.id; /* Only for sp04 */
76}
77
78uint32_t milliseconds_per_tick(void)
79{
80  return CONFIGURE_MICROSECONDS_PER_TICK / 1000;
81}
82
83uint32_t ticks_per_second(void)
84{
85  return rtems_clock_get_ticks_per_second();
86}
87
88size_t work_space_size(void)
89{
90  return rtems_configuration_get_work_space_size()
91    + rtems_configuration_get_stack_space_size();
92}
93
94uint32_t is_configured_multiprocessing(void)
95{
96#if defined(RTEMS_MULTIPROCESSING)
97  return 1;
98#else
99  return 0;
100#endif
101}
102
103uint32_t get_node(void)
104{
105  /* XXX HACK -- use public API */
106  return _Objects_Local_node;
107}
108
109typedef struct {
110  const char *name;
111  long size;
112  long alignment;
113} type_spec;
114
115#define TYPE_SPEC(t) { #t, sizeof(t) * CHAR_BIT, _Alignof(t) }
116
117static const type_spec types[] = {
118  TYPE_SPEC(clockid_t),
119  TYPE_SPEC(pid_t),
120  TYPE_SPEC(pthread_attr_t),
121  TYPE_SPEC(pthread_condattr_t),
122  TYPE_SPEC(pthread_cond_t),
123  TYPE_SPEC(pthread_key_t),
124  TYPE_SPEC(pthread_mutexattr_t),
125  TYPE_SPEC(pthread_mutex_t),
126  TYPE_SPEC(pthread_rwlockattr_t),
127  TYPE_SPEC(pthread_rwlock_t),
128  TYPE_SPEC(pthread_t),
129  TYPE_SPEC(rtems_id),
130  TYPE_SPEC(sigset_t),
131  TYPE_SPEC(stack_t),
132  TYPE_SPEC(struct sched_param),
133  TYPE_SPEC(struct sigaction),
134  TYPE_SPEC(struct timespec)
135};
136
137void check_type(long type, long size, long alignment)
138{
139  if (type >= 0 && type < (long) RTEMS_ARRAY_SIZE(types)) {
140    const type_spec *ts;
141
142    ts = &types[type];
143    printf(
144      "%s: size %li == %li, alignment %li == %li\n",
145      ts->name,
146      ts->size,
147      size,
148      ts->alignment,
149      alignment
150    );
151    if (ts->size != size || ts->alignment != alignment) {
152      exit(0);
153    }
154  } else {
155    exit(0);
156  }
157}
Note: See TracBrowser for help on using the repository browser.