diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 858caaeb4f3..924c5544b50 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2011-12-02 Joel Sherrill + + * s-tpopsp-rtems.adb: Use ATCB_Key rather than RTEMS_Ada_Self variable + for consistency with other ports. + * s-osinte-rtems.adb: Add body for dummy implementation of + pthread_rwlockattr_setkind_np(). + * s-osinte-rtems.ads: Add missing clock and rwlock bindings. + * terminals.c: Add __rtems__ conditionals to account for differences + in termios implementation. + 2011-12-02 Robert Dewar * sem_ch3.adb, sem_attr.adb, a-comutr.adb, a-cbmutr.adb, diff --git a/gcc/ada/s-osinte-rtems.adb b/gcc/ada/s-osinte-rtems.adb index d8e57f692d4..fc99ce4e848 100644 --- a/gcc/ada/s-osinte-rtems.adb +++ b/gcc/ada/s-osinte-rtems.adb @@ -122,4 +122,17 @@ package body System.OS_Interface is 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; diff --git a/gcc/ada/s-osinte-rtems.ads b/gcc/ada/s-osinte-rtems.ads index eb8b17d5f5c..8b9ae1297cd 100644 --- a/gcc/ada/s-osinte-rtems.ads +++ b/gcc/ada/s-osinte-rtems.ads @@ -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 @@ package System.OS_Interface is 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 @@ package System.OS_Interface is 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 @@ package System.OS_Interface is 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 @@ private 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 @@ private 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; diff --git a/gcc/ada/s-tpopsp-rtems.adb b/gcc/ada/s-tpopsp-rtems.adb index 81afc79cb7b..1d672b95324 100644 --- a/gcc/ada/s-tpopsp-rtems.adb +++ b/gcc/ada/s-tpopsp-rtems.adb @@ -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 @@ package body Specific is -- 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 @@ package body Specific is 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 @@ package body Specific is 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 @@ package body Specific is 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 @@ package body Specific is Result : System.Address; begin - Result := RTEMS_Ada_Self; + Result := ATCB_Key; -- If the key value is Null, then it is a non-Ada task. diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c index 464e60a28aa..18a4f2a29bc 100644 --- a/gcc/ada/terminals.c +++ b/gcc/ada/terminals.c @@ -991,7 +991,8 @@ __gnat_setup_winsize (void *desc, int rows, int columns) /* 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 #endif @@ -1142,10 +1143,12 @@ allocate_pty_desc (pty_desc **desc) { 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));