diff mbox

[Ada] Fix tasking on SPARC/Linux

Message ID 201011271830.21638.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou Nov. 27, 2010, 5:30 p.m. UTC
Hi,

tasking is again broken on SPARC/Linux and again because of an alignment bug.

System.OS_Interface for Linux has:

   type pthread_cond_t is array (0 .. 47) of unsigned_char;
   pragma Convention (C, pthread_cond_t);

and the C definition in glibc has:

# define __SIZEOF_PTHREAD_COND_T 48

typedef union
{
  [...]
  char __size[__SIZEOF_PTHREAD_COND_T];
  __extension__ long long int __align;
} pthread_cond_t;

so pthread_cond_t has the alignment of long long.


Unfortunately unsigned_long_long is defined in Interfaces.C.Extensions which 
isn't preelaborated so cannot be with-ed from System.OS_Interface, hence the 
attached patch.  Tested on i586/Linux and SPARC64/Linux, OK for mainline?


2010-11-27  Eric Botcazou  <ebotcazou@adacore.com>

	* s-osinte-linux.ads (sigset_t): Use unsigned_char subtype directly.
	(unsigned_long_long_t): New modular type.
	(pthread_cond_t): Add alignment clause.
diff mbox

Patch

Index: s-osinte-linux.ads
===================================================================
--- s-osinte-linux.ads	(revision 167163)
+++ s-osinte-linux.ads	(working copy)
@@ -507,7 +507,7 @@  package System.OS_Interface is
 
 private
 
-   type sigset_t is array (0 .. 127) of Interfaces.C.unsigned_char;
+   type sigset_t is array (0 .. 127) of unsigned_char;
    pragma Convention (C, sigset_t);
    for sigset_t'Alignment use Interfaces.C.unsigned_long'Alignment;
 
@@ -556,8 +556,12 @@  private
 
    type pthread_mutex_t is new System.Linux.pthread_mutex_t;
 
+   type unsigned_long_long_t is mod 2 ** 64;
+   --  Interfaces.C.Extensions isn't preelaborated so cannot be with-ed
+
    type pthread_cond_t is array (0 .. 47) of unsigned_char;
    pragma Convention (C, pthread_cond_t);
+   for pthread_cond_t'Alignment use unsigned_long_long_t'Alignment;
 
    type pthread_key_t is new unsigned;