ada: Check C and POSIX types

Update #3256.
This commit is contained in:
Sebastian Huber
2017-12-01 22:37:06 +01:00
parent 6c2b8a4b35
commit fd5471b6b7
4 changed files with 187 additions and 3 deletions

View File

@@ -21,12 +21,137 @@ with RTEMS;
with RTEMS.TASKS;
with SPTEST;
with TEST_SUPPORT;
with TEXT_IO;
with System.OS_Interface;
procedure SP01 is
INIT_ID : RTEMS.ID;
STATUS : RTEMS.STATUS_CODES;
obj_clockid_t : System.OS_Interface.clockid_t;
pragma Warnings (Off, obj_clockid_t);
obj_pid_t : System.OS_Interface.pid_t;
pragma Warnings (Off, obj_pid_t);
obj_pthread_attr_t : System.OS_Interface.pthread_attr_t;
pragma Warnings (Off, obj_pthread_attr_t);
obj_pthread_condattr_t : System.OS_Interface.pthread_condattr_t;
pragma Warnings (Off, obj_pthread_condattr_t);
obj_pthread_cond_t : System.OS_Interface.pthread_cond_t;
pragma Warnings (Off, obj_pthread_cond_t);
obj_pthread_key_t : System.OS_Interface.pthread_key_t;
pragma Warnings (Off, obj_pthread_key_t);
obj_pthread_mutexattr_t : System.OS_Interface.pthread_mutexattr_t;
pragma Warnings (Off, obj_pthread_mutexattr_t);
obj_pthread_mutex_t : System.OS_Interface.pthread_mutex_t;
pragma Warnings (Off, obj_pthread_mutex_t);
obj_pthread_rwlockattr_t : System.OS_Interface.pthread_rwlockattr_t;
pragma Warnings (Off, obj_pthread_rwlockattr_t);
obj_pthread_rwlock_t : System.OS_Interface.pthread_rwlock_t;
pragma Warnings (Off, obj_pthread_rwlock_t);
obj_pthread_t : System.OS_Interface.pthread_t;
pragma Warnings (Off, obj_pthread_t);
obj_rtems_id : System.OS_Interface.rtems_id;
pragma Warnings (Off, obj_rtems_id);
obj_sigset_t : System.OS_Interface.sigset_t;
pragma Warnings (Off, obj_sigset_t);
obj_stack_t : System.OS_Interface.stack_t;
pragma Warnings (Off, obj_stack_t);
obj_struct_sched_param : System.OS_Interface.struct_sched_param;
pragma Warnings (Off, obj_struct_sched_param);
obj_struct_sigaction : System.OS_Interface.struct_sigaction;
pragma Warnings (Off, obj_struct_sigaction);
obj_timespec : System.OS_Interface.timespec;
pragma Warnings (Off, obj_timespec);
begin
TEXT_IO.NEW_LINE( 2 );
TEST_SUPPORT.ADA_TEST_BEGIN;
TEST_SUPPORT.Check_Type(
0,
obj_clockid_t'Size,
obj_clockid_t'Alignment
);
TEST_SUPPORT.Check_Type(
1,
obj_pid_t'Size,
obj_pid_t'Alignment
);
TEST_SUPPORT.Check_Type(
2,
obj_pthread_attr_t'Size,
obj_pthread_attr_t'Alignment
);
TEST_SUPPORT.Check_Type(
3,
obj_pthread_condattr_t'Size,
obj_pthread_condattr_t'Alignment
);
TEST_SUPPORT.Check_Type(
4,
obj_pthread_cond_t'Size,
obj_pthread_cond_t'Alignment
);
TEST_SUPPORT.Check_Type(
5,
obj_pthread_key_t'Size,
obj_pthread_key_t'Alignment
);
TEST_SUPPORT.Check_Type(
6,
obj_pthread_mutexattr_t'Size,
obj_pthread_mutexattr_t'Alignment
);
TEST_SUPPORT.Check_Type(
7,
obj_pthread_mutex_t'Size,
obj_pthread_mutex_t'Alignment
);
TEST_SUPPORT.Check_Type(
8,
obj_pthread_rwlockattr_t'Size,
obj_pthread_rwlockattr_t'Alignment
);
TEST_SUPPORT.Check_Type(
9,
obj_pthread_rwlock_t'Size,
obj_pthread_rwlock_t'Alignment
);
TEST_SUPPORT.Check_Type(
10,
obj_pthread_t'Size,
obj_pthread_t'Alignment
);
TEST_SUPPORT.Check_Type(
11,
obj_rtems_id'Size,
obj_rtems_id'Alignment
);
TEST_SUPPORT.Check_Type(
12,
obj_sigset_t'Size,
obj_sigset_t'Alignment
);
TEST_SUPPORT.Check_Type(
13,
obj_stack_t'Size,
obj_stack_t'Alignment
);
TEST_SUPPORT.Check_Type(
14,
obj_struct_sched_param'Size,
obj_struct_sched_param'Alignment
);
TEST_SUPPORT.Check_Type(
15,
obj_struct_sigaction'Size,
obj_struct_sigaction'Alignment
);
TEST_SUPPORT.Check_Type(
16,
obj_timespec'Size,
obj_timespec'Alignment
);
RTEMS.TASKS.CREATE(
RTEMS.BUILD_NAME( 'I', 'N', 'I', 'T' ),
1,

View File

@@ -37,9 +37,6 @@ package body SPTEST is
STATUS : RTEMS.STATUS_CODES;
begin
TEXT_IO.NEW_LINE( 2 );
TEST_SUPPORT.ADA_TEST_BEGIN;
TIME := ( 1988, 12, 31, 9, 0, 0, 0 );
RTEMS.CLOCK.SET( TIME, STATUS );

View File

@@ -3,8 +3,13 @@
* On-Line Applications Research Corporation (OAR).
*/
#include <sys/types.h>
#include <limits.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <rtems.h>
#include <rtems/test.h>
#include <rtems/score/threadimpl.h>
@@ -34,6 +39,7 @@ uint32_t work_space_size(void);
uint32_t is_configured_multiprocessing(void);
uint32_t get_node(void);
rtems_id tcb_to_id(Thread_Control *tcb);
void check_type(long type, long size, long alignment);
/*
* By putting this in brackets rather than quotes, we get the search
@@ -99,3 +105,52 @@ uint32_t get_node(void)
return _Objects_Local_node;
}
typedef struct {
const char *name;
long size;
long alignment;
} type_spec;
#define TYPE_SPEC(t) { #t, sizeof(t) * CHAR_BIT, _Alignof(t) }
static const type_spec types[] = {
TYPE_SPEC(clockid_t),
TYPE_SPEC(pid_t),
TYPE_SPEC(pthread_attr_t),
TYPE_SPEC(pthread_condattr_t),
TYPE_SPEC(pthread_cond_t),
TYPE_SPEC(pthread_key_t),
TYPE_SPEC(pthread_mutexattr_t),
TYPE_SPEC(pthread_mutex_t),
TYPE_SPEC(pthread_rwlockattr_t),
TYPE_SPEC(pthread_rwlock_t),
TYPE_SPEC(pthread_t),
TYPE_SPEC(rtems_id),
TYPE_SPEC(sigset_t),
TYPE_SPEC(stack_t),
TYPE_SPEC(struct sched_param),
TYPE_SPEC(struct sigaction),
TYPE_SPEC(struct timespec)
};
void check_type(long type, long size, long alignment)
{
if (type >= 0 && type < (long) RTEMS_ARRAY_SIZE(types)) {
const type_spec *ts;
ts = &types[type];
printf(
"%s: size %li == %li, alignment %li == %li\n",
ts->name,
ts->size,
size,
ts->alignment,
alignment
);
if (ts->size != size || ts->alignment != alignment) {
exit(0);
}
} else {
exit(0);
}
}

View File

@@ -28,6 +28,13 @@ package Test_Support is
procedure Ada_Test_End;
pragma Import (C, Ada_Test_End, "ada_test_end");
procedure Check_Type(
t : in Long_Integer;
s : in Long_Integer;
a : in Long_Integer
);
pragma Import (C, Check_Type, "check_type");
--
-- Fatal_Directive_Status
--