This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Export _NCPUWORDS as variable for access from within the gnat-rts




On 10/29/2015 9:20 AM, Jan Sommer wrote:
Am Thursday 29 October 2015, 08:45:57 schrieb Joel Sherrill:

On 10/29/2015 8:14 AM, Jan Sommer wrote:
Hi,

This patch will make the define _NCPUWORDS accessible for the ada runtime. It is necessary to model the pthread_attr_t implementation for rtems  in Ada.
We had a stack corruption because the C an Ada declarations of the type where out of synch.
I will send the updated s-osinte-rtems.ads to  gcc if this patch is accepted.

I put devel@rtems.org CC for input from the rtems developers.


Is it possible to define this in the RTEMS Ada glue file?


What is the rtems Ada glue file?

There are two support files in cpukit/libgnat. I looked through
the git log history of these files and it is quite boring. But
there isn't much code here, it is target independent, and might
be worth a double check. Better that than debugging something
else.

There is also some BSP specific code to map exceptions into
Ada exceptions. Some is in libbsp/shared. From memory, the sparc
BSPs have the exception propagation glue.

Just to clarify: The problem I had was that pthread_attr_t has a field of

typedef struct _cpuset {
   cpu_set_word_t __bits[_NCPUWORDS];
} cpu_set_t;

which's length depends on _NCPUWORDS.
In ada I added types like this:

    NUMCPUWORDS : constant size_t;

    pragma Import (
       Convention    => C,
       Entity        => NUMCPUWORDS,
       External_Name => "_ADA_NCPUWORDS"
    );

    type cpu_set_array is array (0 .. NUMCPUWORDS) of
       aliased cpu_set_word_t;

    type cpu_set_t is record
        bits : aliased cpu_set_array;
    end record;

I just put it into newlib, because I thought the export should be close to the original declaration.
If you can point to a better fitting location I am happy to put it there.

There are a handful of similar cases handled in libgnat.
You have to have real C variables or methods to use
macros.

Best regards,

    Jan

Generally, I like the Ada support to be self-contained and
have no impact on anything else. This puts an Ada specific
variable in generic code.

This is similar to how I had to do the Ada task minimum
stack size. It could have gone in more common code but
nothing else uses it so should not be impacted.

Plus newlib doesn't know anything about our Ada glue layer.
Best to keep it that way.

Best regards,

      Jan


_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


--
Joel Sherrill, Ph.D.
Check out RTEMS at https://www.rtems.org
Truly free real-time operating sysem


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]