Hi,
The attached patch is necessary to let the gcc head
compile Ada for *-*-rtems*. Other than terminals.c,
the files impacted are RTEMS specific. OK to commit?
I have posted ACATS results for sparc-rtems4.11 at
http://gcc.gnu.org/ml/gcc-testresults/2011-12/msg00108.html
These are better results than what I posted back in
April for a 4.6.1 prerelease:
http://gcc.gnu.org/ml/gcc-testresults/2011-04/msg00209.html
2011-12-01 Joel Sherrill <joel.sherr...@oarcorp.com>
* gcc/ada/s-tpopsp-rtems.adb: Use ATCB_Key rather than
RTEMS_Ada_Self variable for consistency with other ports.
* gcc/ada/s-osinte-rtems.adb: Add body for dummy implementation
of pthread_rwlockattr_setkind_np().
* gcc/ada/s-osinte-rtems.ads: Add missing clock and rwlock
bindings.
* gcc/ada/terminals.c: Add __rtems__ conditionals to account
for differences in termios implementation.
--
Joel Sherrill, Ph.D. Director of Research& Development
joel.sherr...@oarcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
2011-12-01 Joel Sherrill <joel.sherr...@oarcorp.com>
* gcc/ada/s-tpopsp-rtems.adb: Use ATCB_Key rather than
RTEMS_Ada_Self variable for consistency with other ports.
* gcc/ada/s-osinte-rtems.adb: Add body for dummy implementation
of pthread_rwlockattr_setkind_np().
* gcc/ada/s-osinte-rtems.ads: Add missing clock and rwlock bindings.
* gcc/ada/terminals.c: Add __rtems__ conditionals to account
for differences in termios implementation.
Index: gcc/ada/s-tpopsp-rtems.adb
===================================================================
--- gcc/ada/s-tpopsp-rtems.adb (revision 181881)
+++ gcc/ada/s-tpopsp-rtems.adb (working copy)
@@ -10,7 +10,7 @@
-- $Revision: 1.2 $
-- --
-- Copyright (C) 1991-2003, Florida State University --
--- Copyright (C) 2008, Free Software Foundation, Inc. --
+-- Copyright (C) 2008-2011, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -48,8 +48,8 @@
-- The following gives the Ada run-time direct access to a variable
-- context switched by RTEMS at the lowest level.
- RTEMS_Ada_Self : System.Address;
- pragma Import (C, RTEMS_Ada_Self, "rtems_ada_self");
+ ATCB_Key : System.Address;
+ pragma Import (C, ATCB_Key, "rtems_ada_self");
----------------
-- Initialize --
@@ -59,8 +59,7 @@
pragma Warnings (Off, Environment_Task);
begin
- ATCB_Key := No_Key;
- RTEMS_Ada_Self := To_Address (Environment_Task);
+ ATCB_Key := To_Address (Environment_Task);
end Initialize;
-------------------
@@ -69,7 +68,7 @@
function Is_Valid_Task return Boolean is
begin
- return RTEMS_Ada_Self /= System.Null_Address;
+ return ATCB_Key /= System.Null_Address;
end Is_Valid_Task;
---------
@@ -78,7 +77,7 @@
procedure Set (Self_Id : Task_Id) is
begin
- RTEMS_Ada_Self := To_Address (Self_Id);
+ ATCB_Key := To_Address (Self_Id);
end Set;
----------
@@ -102,7 +101,7 @@
Result : System.Address;
begin
- Result := RTEMS_Ada_Self;
+ Result := ATCB_Key;
-- If the key value is Null, then it is a non-Ada task.
Index: gcc/ada/s-osinte-rtems.adb
===================================================================
--- gcc/ada/s-osinte-rtems.adb (revision 181881)
+++ gcc/ada/s-osinte-rtems.adb (working copy)
@@ -122,4 +122,17 @@
return 0;
end sigaltstack;
+ -----------------------------------
+ -- pthread_rwlockattr_setkind_np --
+ -----------------------------------
+
+ function pthread_rwlockattr_setkind_np
+ (attr : access pthread_rwlockattr_t;
+ pref : int) return int is
+ pragma Unreferenced (attr);
+ pragma Unreferenced (pref);
+ begin
+ return 0;
+ end pthread_rwlockattr_setkind_np;
+
end System.OS_Interface;
Index: gcc/ada/s-osinte-rtems.ads
===================================================================
--- gcc/ada/s-osinte-rtems.ads (revision 181881)
+++ gcc/ada/s-osinte-rtems.ads (working copy)
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1997-2009 Free Software Foundation, Inc. --
+-- Copyright (C) 1997-2011 Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -176,9 +176,10 @@
type timespec is private;
- type clockid_t is private;
+ type clockid_t is new int;
- CLOCK_REALTIME : constant clockid_t;
+ CLOCK_REALTIME : constant clockid_t;
+ CLOCK_MONOTONIC : constant clockid_t;
function clock_gettime
(clock_id : clockid_t;
@@ -236,12 +237,14 @@
type pthread_t is private;
subtype Thread_Id is pthread_t;
- type pthread_mutex_t is limited private;
- type pthread_cond_t is limited private;
- type pthread_attr_t is limited private;
- type pthread_mutexattr_t is limited private;
- type pthread_condattr_t is limited private;
- type pthread_key_t is private;
+ type pthread_mutex_t is limited private;
+ type pthread_rwlock_t is limited private;
+ type pthread_cond_t is limited private;
+ type pthread_attr_t is limited private;
+ type pthread_mutexattr_t is limited private;
+ type pthread_rwlockattr_t is limited private;
+ type pthread_condattr_t is limited private;
+ type pthread_key_t is private;
No_Key : constant pthread_key_t;
@@ -353,6 +356,40 @@
function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
+ function pthread_rwlockattr_init
+ (attr : access pthread_rwlockattr_t) return int;
+ pragma Import (C, pthread_rwlockattr_init, "pthread_rwlockattr_init");
+
+ function pthread_rwlockattr_destroy
+ (attr : access pthread_rwlockattr_t) return int;
+ pragma Import (C, pthread_rwlockattr_destroy, "pthread_rwlockattr_destroy");
+
+ PTHREAD_RWLOCK_PREFER_READER_NP : constant := 0;
+ PTHREAD_RWLOCK_PREFER_WRITER_NP : constant := 1;
+ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+
+ function pthread_rwlockattr_setkind_np
+ (attr : access pthread_rwlockattr_t;
+ pref : int) return int;
+
+ function pthread_rwlock_init
+ (mutex : access pthread_rwlock_t;
+ attr : access pthread_rwlockattr_t) return int;
+ pragma Import (C, pthread_rwlock_init, "pthread_rwlock_init");
+
+ function pthread_rwlock_destroy
+ (mutex : access pthread_rwlock_t) return int;
+ pragma Import (C, pthread_rwlock_destroy, "pthread_rwlock_destroy");
+
+ function pthread_rwlock_rdlock (mutex : access pthread_rwlock_t) return int;
+ pragma Import (C, pthread_rwlock_rdlock, "pthread_rwlock_rdlock");
+
+ function pthread_rwlock_wrlock (mutex : access pthread_rwlock_t) return int;
+ pragma Import (C, pthread_rwlock_wrlock, "pthread_rwlock_wrlock");
+
+ function pthread_rwlock_unlock (mutex : access pthread_rwlock_t) return int;
+ pragma Import (C, pthread_rwlock_unlock, "pthread_rwlock_unlock");
+
function pthread_condattr_init
(attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
@@ -584,8 +621,8 @@
end record;
pragma Convention (C, timespec);
- type clockid_t is new rtems_id;
- CLOCK_REALTIME : constant clockid_t := 1;
+ CLOCK_REALTIME : constant clockid_t := 1;
+ CLOCK_MONOTONIC : constant clockid_t := 4;
type pthread_attr_t is record
is_initialized : int;
@@ -616,10 +653,18 @@
end record;
pragma Convention (C, pthread_mutexattr_t);
+ type pthread_rwlockattr_t is record
+ is_initialized : int;
+ process_shared : int;
+ end record;
+ pragma Convention (C, pthread_rwlockattr_t);
+
type pthread_t is new rtems_id;
type pthread_mutex_t is new rtems_id;
+ type pthread_rwlock_t is new rtems_id;
+
type pthread_cond_t is new rtems_id;
type pthread_key_t is new rtems_id;
Index: gcc/ada/terminals.c
===================================================================
--- gcc/ada/terminals.c (revision 181881)
+++ gcc/ada/terminals.c (working copy)
@@ -991,7 +991,8 @@
/* On some system termio is either absent or including it will disable termios
(HP-UX) */
-#if ! defined (__hpux__) && ! defined (FREEBSD) && ! defined (__APPLE__)
+#if ! defined (__hpux__) && ! defined (FREEBSD) && \
+ ! defined (__APPLE__) && ! defined(__rtems__)
# include <termio.h>
#endif
@@ -1142,10 +1143,12 @@
return -1;
}
+#if !defined(__rtems__)
/* grant access to the slave side */
grantpt (master_fd);
/* unlock the terminal */
unlockpt (master_fd);
+#endif
/* set desc and return 0 */
result = malloc (sizeof (pty_desc));