Description: add support for GNU/kFreeBSD and GNU/Hurd.
 For now, it seems that BSD requires -lrt.
 On other architectures, the library is ignored thanks to --as-needed.
Author: Ludovic Brenta <lbrenta@debian.org>
Author: Nicolas Boulenguez <nicolas@debian.org>

--- a/src/gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads
+++ b/src/gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads
@@ -45,6 +45,7 @@ package System.OS_Interface is
    pragma Preelaborate;
 
    pragma Linker_Options ("-lpthread");
+   pragma Linker_Options ("-lrt");
 
    subtype int            is Interfaces.C.int;
    subtype char           is Interfaces.C.char;
@@ -437,31 +438,25 @@ package System.OS_Interface is
    PTHREAD_PRIO_PROTECT : constant := 2;
    PTHREAD_PRIO_INHERIT : constant := 1;
 
+   --  GNU/kFreeBSD does not support Thread Priority Protection or Thread
+   --  Priority Inheritance and lacks some pthread_mutexattr_* functions.
+   --  Replace them with dummy versions.
+
    function pthread_mutexattr_setprotocol
-     (attr     : access pthread_mutexattr_t;
-      protocol : int) return int;
-   pragma Import
-      (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
+     (ignored_attr     : access pthread_mutexattr_t;
+      ignored_protocol : int) return int is (0);
 
    function pthread_mutexattr_getprotocol
-     (attr     : access pthread_mutexattr_t;
-      protocol : access int) return int;
-   pragma Import
-     (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
+     (ignored_attr     : access pthread_mutexattr_t;
+      ignored_protocol : access int) return int is (0);
 
    function pthread_mutexattr_setprioceiling
-     (attr     : access pthread_mutexattr_t;
-      prioceiling : int) return int;
-   pragma Import
-     (C, pthread_mutexattr_setprioceiling,
-      "pthread_mutexattr_setprioceiling");
+     (ignored_attr     : access pthread_mutexattr_t;
+      ignored_prioceiling : int) return int is (0);
 
    function pthread_mutexattr_getprioceiling
-     (attr     : access pthread_mutexattr_t;
-      prioceiling : access int) return int;
-   pragma Import
-     (C, pthread_mutexattr_getprioceiling,
-      "pthread_mutexattr_getprioceiling");
+     (ignored_attr     : access pthread_mutexattr_t;
+      ignored_prioceiling : access int) return int is (0);
 
    type struct_sched_param is record
       sched_priority : int;  --  scheduling priority
--- a/src/gcc/ada/s-oscons-tmplt.c
+++ b/src/gcc/ada/s-oscons-tmplt.c
@@ -1940,6 +1940,7 @@ CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU
 
 #if defined(__linux__) || defined(__FreeBSD__) \
  || (defined(_AIX) && defined(_AIXVERSION_530)) \
+ || defined(__FreeBSD_kernel__) \
  || defined(__DragonFly__) || defined(__QNX__)
 /** On these platforms use system provided monotonic clock instead of
  ** the default CLOCK_REALTIME. We then need to set up cond var attributes
