File indexing completed on 2025-05-11 08:24:28
0001
0002
0003
0004
0005
0006 #include <sys/types.h>
0007 #include <limits.h>
0008 #include <pthread.h>
0009 #include <stdio.h>
0010 #include <stdlib.h>
0011
0012 #include <rtems.h>
0013 #include <rtems/test-info.h>
0014 #include <rtems/score/threadimpl.h>
0015
0016
0017
0018
0019 extern int gnat_main ( int argc, char **argv, char **envp );
0020
0021 static void *POSIX_Init(
0022 void *argument
0023 )
0024 {
0025 (void) gnat_main ( 0, 0, 0 );
0026
0027 exit( 0 );
0028 }
0029
0030
0031
0032
0033
0034 void ada_test_begin(void);
0035 void ada_test_end(void);
0036 uint32_t milliseconds_per_tick(void);
0037 uint32_t ticks_per_second(void);
0038 size_t work_space_size(void);
0039 uint32_t is_configured_multiprocessing(void);
0040 uint32_t get_node(void);
0041 rtems_id tcb_to_id(Thread_Control *tcb);
0042 void check_type(long type, long size, long alignment);
0043
0044
0045
0046
0047
0048 #define CONFIGURE_INIT
0049
0050 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0051
0052 #include <rtems/confdefs.h>
0053
0054 const char rtems_test_name[] = ADA_TEST_NAME;
0055
0056 void ada_test_begin(void)
0057 {
0058 rtems_test_begin(rtems_test_name, RTEMS_TEST_STATE_PASS);
0059 }
0060
0061 void ada_test_end(void)
0062 {
0063 fsync(STDOUT_FILENO);
0064 rtems_test_end(rtems_test_name);
0065 }
0066
0067 rtems_id tcb_to_id(
0068 Thread_Control *tcb
0069 )
0070 {
0071 return tcb->Object.id;
0072 }
0073
0074 uint32_t milliseconds_per_tick(void)
0075 {
0076 return CONFIGURE_MICROSECONDS_PER_TICK / 1000;
0077 }
0078
0079 uint32_t ticks_per_second(void)
0080 {
0081 return rtems_clock_get_ticks_per_second();
0082 }
0083
0084 size_t work_space_size(void)
0085 {
0086 return rtems_configuration_get_work_space_size()
0087 + rtems_configuration_get_stack_space_size();
0088 }
0089
0090 uint32_t is_configured_multiprocessing(void)
0091 {
0092 #if defined(RTEMS_MULTIPROCESSING)
0093 return 1;
0094 #else
0095 return 0;
0096 #endif
0097 }
0098
0099 uint32_t get_node(void)
0100 {
0101 return rtems_object_get_local_node();
0102 }
0103
0104 typedef struct {
0105 const char *name;
0106 long size;
0107 long alignment;
0108 } type_spec;
0109
0110 #define TYPE_SPEC(t) { #t, sizeof(t) * CHAR_BIT, _Alignof(t) }
0111
0112 static const type_spec types[] = {
0113 TYPE_SPEC(clockid_t),
0114 TYPE_SPEC(pid_t),
0115 TYPE_SPEC(pthread_attr_t),
0116 TYPE_SPEC(pthread_condattr_t),
0117 TYPE_SPEC(pthread_cond_t),
0118 TYPE_SPEC(pthread_key_t),
0119 TYPE_SPEC(pthread_mutexattr_t),
0120 TYPE_SPEC(pthread_mutex_t),
0121 TYPE_SPEC(pthread_rwlockattr_t),
0122 TYPE_SPEC(pthread_rwlock_t),
0123 TYPE_SPEC(pthread_t),
0124 TYPE_SPEC(rtems_id),
0125 TYPE_SPEC(sigset_t),
0126 TYPE_SPEC(stack_t),
0127 TYPE_SPEC(struct sched_param),
0128 TYPE_SPEC(struct sigaction),
0129 TYPE_SPEC(struct timespec)
0130 };
0131
0132 void check_type(long type, long size, long alignment)
0133 {
0134 if (type >= 0 && type < (long) RTEMS_ARRAY_SIZE(types)) {
0135 const type_spec *ts;
0136
0137 ts = &types[type];
0138 printf(
0139 "%s: size %li == %li, alignment %li == %li\n",
0140 ts->name,
0141 ts->size,
0142 size,
0143 ts->alignment,
0144 alignment
0145 );
0146 if (ts->size != size || ts->alignment != alignment) {
0147 exit(0);
0148 }
0149 } else {
0150 exit(0);
0151 }
0152 }