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 02/21/18 at 11:40:18

Add a simple task console driver

Close #3320.

  • Property mode set to 100644
File size: 3.2 KB
RevLine 
[3495c57]1/*
[d138a22b]2 *  COPYRIGHT (c) 1989-2015
[f3f06f79]3 *  On-Line Applications Research Corporation (OAR).
4 */
5
[fd5471b]6#include <sys/types.h>
7#include <limits.h>
8#include <pthread.h>
9#include <stdio.h>
[698b292]10#include <stdlib.h>
[f3f06f79]11
[fd5471b]12#include <rtems.h>
[f6c9334d]13#include <rtems/test.h>
[d138a22b]14#include <rtems/score/threadimpl.h>
15
[110e1f1]16/*
17 * This is the entry point automatically generated by GNAT.
18 */
19extern int gnat_main ( int argc, char **argv, char **envp );
20
[d138a22b]21static void *POSIX_Init(
[f3f06f79]22  void *argument
23)
24{
25  (void) gnat_main ( 0, 0, 0 );
26
27  exit( 0 );
28}
29
[d0f426a1]30/*
[d138a22b]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.
[d0f426a1]33 */
[f6c9334d]34void ada_test_begin(void);
35void ada_test_end(void);
[d138a22b]36uint32_t milliseconds_per_tick(void);
37uint32_t ticks_per_second(void);
[bc96f3b4]38size_t work_space_size(void);
[d138a22b]39uint32_t is_configured_multiprocessing(void);
40uint32_t get_node(void);
41rtems_id tcb_to_id(Thread_Control *tcb);
[fd5471b]42void check_type(long type, long size, long alignment);
[23848bbd]43
[a47bd655]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 */
[f3f06f79]48#define CONFIGURE_INIT
[0f9e7f96]49#define CONFIGURE_GNAT_RTEMS
[16e8d3d]50#define CONFIGURE_MEMORY_OVERHEAD  (256)
[0f9e7f96]51
[f6c9334d]52#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
53
[c589775a]54#define CONFIGURE_DISABLE_SMP_CONFIGURATION
55
[a47bd655]56#include <config.h>
[23848bbd]57
[f6c9334d]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{
[337a186]67  fsync(STDOUT_FILENO);
[f6c9334d]68  rtems_test_end(rtems_test_name);
69}
70
[d138a22b]71rtems_id tcb_to_id(
72  Thread_Control *tcb
73)
74{
[d5154d0f]75  return tcb->Object.id; /* Only for sp04 */
[d138a22b]76}
77
[23848bbd]78uint32_t milliseconds_per_tick(void)
79{
80  return CONFIGURE_MICROSECONDS_PER_TICK / 1000;
81}
82
83uint32_t ticks_per_second(void)
84{
[88c74ab]85  return rtems_clock_get_ticks_per_second();
[23848bbd]86}
87
[bc96f3b4]88size_t work_space_size(void)
[ba3e1a4f]89{
[6e05265f]90  return rtems_configuration_get_work_space_size()
91    + rtems_configuration_get_stack_space_size();
[ba3e1a4f]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
[23848bbd]103uint32_t get_node(void)
104{
105  /* XXX HACK -- use public API */
106  return _Objects_Local_node;
107}
[d138a22b]108
[fd5471b]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.