From 1dab7b355e2f51c4fd3aedecb304f15bfee99d6c Mon Sep 17 00:00:00 2001
From: Aurelien Jarno <aurelien@aurel32.net>
Date: Mon, 7 Apr 2008 12:30:03 +0000
Subject: [PATCH] s-osinte-linux-kfreebsd.ads (SC_NPROCESSORS_ONLN): New
 constant constant for sysconf call.

2008-04-07  Aurelien Jarno  <aurelien@aurel32.net>

        * s-osinte-linux-kfreebsd.ads (SC_NPROCESSORS_ONLN): New
        constant constant for sysconf call.
        (bit_field): New packed boolean type used by cpu_set_t.
        (cpu_set_t): New type corresponding to the C type with
        the same name. Note that on the Ada side we use a bit
        field array for the affinity mask. There is not need
        for the C macro for setting individual bit.
        (pthread_setaffinity_np): New imported routine.
        * Makefile.in: Use s-tasinf-linux.ads and s-tasinf-linux.adb
        on GNU/kFreeBSD.

From-SVN: r133978
---
 gcc/ada/ChangeLog                 | 13 +++++++++++++
 gcc/ada/Makefile.in               |  2 ++
 gcc/ada/s-osinte-kfreebsd-gnu.ads | 23 ++++++++++++++++++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 826cd0dfa998..c4ed0e7df24d 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,16 @@
+2008-04-07  Aurelien Jarno  <aurelien@aurel32.net>
+
+	* s-osinte-linux-kfreebsd.ads (SC_NPROCESSORS_ONLN): New 
+	constant constant for sysconf call.
+	(bit_field): New packed boolean type used by cpu_set_t.
+	(cpu_set_t): New type corresponding to the C type with
+	the same name. Note that on the Ada side we use a bit
+	field array for the affinity mask. There is not need
+	for the C macro for setting individual bit.
+	(pthread_setaffinity_np): New imported routine.
+	* Makefile.in: Use s-tasinf-linux.ads and s-tasinf-linux.adb
+	on GNU/kFreeBSD.
+
 2008-04-07  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* utils2.c (build_binary_op): Fold ARRAY_REF and ARRAY_RANGE_REF too.
diff --git a/gcc/ada/Makefile.in b/gcc/ada/Makefile.in
index c27e7e216a10..291b0a8f79c6 100644
--- a/gcc/ada/Makefile.in
+++ b/gcc/ada/Makefile.in
@@ -892,6 +892,8 @@ ifeq ($(strip $(filter-out %86 kfreebsd%,$(arch) $(osys))),)
   s-osinte.ads<s-osinte-kfreebsd-gnu.ads \
   s-osprim.adb<s-osprim-posix.adb \
   s-taprop.adb<s-taprop-linux.adb \
+  s-tasinf.ads<s-tasinf-linux.ads \
+  s-tasinf.adb<s-tasinf-linux.adb \
   s-taspri.ads<s-taspri-posix.ads \
   s-tpopsp.adb<s-tpopsp-posix-foreign.adb \
   system.ads<system-freebsd-x86.ads
diff --git a/gcc/ada/s-osinte-kfreebsd-gnu.ads b/gcc/ada/s-osinte-kfreebsd-gnu.ads
index 05fb928fbbb7..17c112905002 100644
--- a/gcc/ada/s-osinte-kfreebsd-gnu.ads
+++ b/gcc/ada/s-osinte-kfreebsd-gnu.ads
@@ -223,7 +223,8 @@ package System.OS_Interface is
    function sysconf (name : int) return long;
    pragma Import (C, sysconf);
 
-   SC_CLK_TCK : constant := 2;
+   SC_CLK_TCK          : constant := 2;
+   SC_NPROCESSORS_ONLN : constant := 84;
 
    -------------------------
    -- Priority Scheduling --
@@ -255,6 +256,7 @@ package System.OS_Interface is
 
    type Thread_Body is access
      function (arg : System.Address) return System.Address;
+   pragma Convention (C, Thread_Body);
 
    function Thread_Body_Access is new
      Unchecked_Conversion (System.Address, Thread_Body);
@@ -438,12 +440,31 @@ package System.OS_Interface is
    pragma Import (C, pthread_getspecific, "pthread_getspecific");
 
    type destructor_pointer is access procedure (arg : System.Address);
+   pragma Convention (C, destructor_pointer);
 
    function pthread_key_create
      (key        : access pthread_key_t;
       destructor : destructor_pointer) return int;
    pragma Import (C, pthread_key_create, "pthread_key_create");
 
+   CPU_SETSIZE : constant := 1_024;
+
+   type bit_field is array (1 .. CPU_SETSIZE) of Boolean;
+   for bit_field'Size use CPU_SETSIZE;
+   pragma Pack (bit_field);
+   pragma Convention (C, bit_field);
+
+   type cpu_set_t is record
+      bits : bit_field;
+   end record;
+   pragma Convention (C, cpu_set_t);
+
+   function pthread_setaffinity_np
+     (thread     : pthread_t;
+      cpusetsize : size_t;
+      cpuset     : access cpu_set_t) return int;
+   pragma Import (C, pthread_setaffinity_np, "__gnat_pthread_setaffinity_np");
+
 private
 
    type sigset_t is array (1 .. 4) of unsigned;