[PATCH] Fix declaration of pthread-structs in s-osinte-rtems.ads

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Nov 2 11:39:57 UTC 2015



On 31/10/15 16:47, Jan Sommer wrote:
> Hi,
>
> This patch changes the Ada-declaration of the pthread-related structs such as pthread_attr_t from a field-equivalent declaration to just reserving the right amount of memory.
> It is only rtems related and essentially copies the way how the types are defined in s-osinte-linux.ads. It makes the declarations independent of a particular newlib-version and fixes the bug I filed here:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68169

[...]

>      -------------
>      -- Signals --
> @@ -448,6 +450,7 @@ package System.OS_Interface is
>         ss_low_priority     : int;
>         ss_replenish_period : timespec;
>         ss_initial_budget   : timespec;
> +      sched_ss_max_repl   : int;
>      end record;
>      pragma Convention (C, struct_sched_param);

Why is this structure not changed to an opaque size + alignment type 
like the other structures?

>   
> @@ -621,43 +624,34 @@ private
>      end record;
>      pragma Convention (C, timespec);
>   
> -   CLOCK_REALTIME :  constant clockid_t := 1;
> -   CLOCK_MONOTONIC : constant clockid_t := 4;
> +   CLOCK_REALTIME :  constant clockid_t := System.OS_Constants.CLOCK_REALTIME;
> +   CLOCK_MONOTONIC : constant clockid_t := System.OS_Constants.CLOCK_MONOTONIC;
> +
> +   subtype char_array is Interfaces.C.char_array;
>   
>      type pthread_attr_t is record
> -      is_initialized  : int;
> -      stackaddr       : System.Address;
> -      stacksize       : int;
> -      contentionscope : int;
> -      inheritsched    : int;
> -      schedpolicy     : int;
> -      schedparam      : struct_sched_param;
> -      cputime_clocked_allowed : int;
> -      detatchstate    : int;
> +      Data : char_array (1 .. OS_Constants.PTHREAD_ATTR_SIZE);
>      end record;
>      pragma Convention (C, pthread_attr_t);
> +   for pthread_attr_t'Alignment use Interfaces.C.unsigned_long'Alignment;
>   
>      type pthread_condattr_t is record
> -      flags           : int;
> -      process_shared  : int;
> +      Data : char_array (1 .. OS_Constants.PTHREAD_CONDATTR_SIZE);
>      end record;
>      pragma Convention (C, pthread_condattr_t);
> +   for pthread_condattr_t'Alignment use Interfaces.C.int'Alignment;
>   
>      type pthread_mutexattr_t is record
> -      is_initialized  : int;
> -      process_shared  : int;
> -      prio_ceiling    : int;
> -      protocol        : int;
> -      mutex_type      : int;
> -      recursive       : int;
> -   end record;
> +      Data : char_array (1 .. OS_Constants.PTHREAD_MUTEXATTR_SIZE);
> +   end  record;
>      pragma Convention (C, pthread_mutexattr_t);
> +   for pthread_mutexattr_t'Alignment use Interfaces.C.int'Alignment;
[...]

The alignment is sometimes int and sometimes unsigned long. I would 
change this to long long or double throughout, e.g. if we change the CPU 
mask type to uint64_t, then the alignment specified here is no longer 
correct.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list