[PATCH 2/2] Export _NCPUWORDS for Ada

Jan Sommer soja-lists at aries.uberspace.de
Fri Oct 30 08:53:35 UTC 2015


Am Friday 30 October 2015, 07:50:16 schrieb Sebastian Huber:
> How is this tackled in the glibc/Linux support? Is the exact layout of 
> the structures really interesting for Ada? I guess its sufficient to 
> tell Ada the size and alignment of pthread_attr_t for example.
> 

In Linux they do it like this:
   type pthread_attr_t is record
      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;

That's probably the best solution. The gnat-rts changes values of the fields only using the corresponding pthread_set functions.
If no one objects I would try to change the osinte-rtems.ads in the same manner.


> On 29/10/15 22:10, Jan Sommer wrote:
> > _NCPUWORDS is defined in newlib in newlib/libc/sys/rtems/sys/cpuset.h and used to define the type cpu_set_t there.
> > typedef struct _cpuset {
> >    cpu_set_word_t __bits[_NCPUWORDS];
> > } cpu_set_t;
> > cpu_set_t is used for a field in the struct pthread_attr_t in file newlib/libc/include/types.h
> >
> > The Gnat Ada runtime uses POSIX-threads for tasking, therefore the pthread-types have to be declared in Ada in order to import them.
> > As the fixed size array in cpu_set_t depends on the value of _NCPUWORDS it is exported with the symbol _ada_ncpuwords in order to access it from within the Ada runtime.
> >
> > The Ada declaration of pthread_attr_t is located in gcc/ada/s-osinte-rtems.ads and _ada_ncpuwords is imported there.
> > ---
> >   cpukit/libgnat/adasupp.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/cpukit/libgnat/adasupp.c b/cpukit/libgnat/adasupp.c
> > index 662b1cc..cde36b6 100644
> > --- a/cpukit/libgnat/adasupp.c
> > +++ b/cpukit/libgnat/adasupp.c
> > @@ -10,6 +10,10 @@
> >   #include <rtems/posix/pthreadimpl.h>
> >   #include <rtems/score/stackimpl.h>
> >   
> > +
> > +/* export _NCPUWORDS for Ada */
> > +const size_t _ada_ncpuwords = _NCPUWORDS - 1;
> > +
> >   /*
> >    *  _ada_pthread_minimum_stack_size
> >    *
> 
> 




More information about the devel mailing list