summaryrefslogtreecommitdiff
path: root/gcc/ada/s-osinte-linux.ads
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-13 10:18:44 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-13 10:18:44 +0000
commite2a33c1825a7cbbb0061b24d7fccf70c172ddd5e (patch)
treeaab7a215c62fc85b658d90381374889f961afcaa /gcc/ada/s-osinte-linux.ads
parent85b21747512bbed0231baff8af70125cdd9c5899 (diff)
downloadgcc-e2a33c1825a7cbbb0061b24d7fccf70c172ddd5e.tar.gz
2007-12-06 Pascal Obry <obry@adacore.com>
* adaint.c (__gnat_pthread_setaffinity_np): New routine. A dummy version is provided for older GNU/Linux distribution not supporting thread affinity sets. * s-osinte-linux.ads (SC_NPROCESSORS_ONLN): New 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. * s-taprop-linux.adb (Enter_Task): Check that the CPU affinity mask is no null. (Create_Task): Set the processor affinity mask if information is present. * s-tasinf-linux.ads, s-tasinf-linux.adb: New files. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130812 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-osinte-linux.ads')
-rw-r--r--gcc/ada/s-osinte-linux.ads25
1 files changed, 23 insertions, 2 deletions
diff --git a/gcc/ada/s-osinte-linux.ads b/gcc/ada/s-osinte-linux.ads
index 751e3b8238a..7299123deb7 100644
--- a/gcc/ada/s-osinte-linux.ads
+++ b/gcc/ada/s-osinte-linux.ads
@@ -241,7 +241,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 --
@@ -253,7 +254,7 @@ package System.OS_Interface is
function To_Target_Priority
(Prio : System.Any_Priority) return Interfaces.C.int;
- -- Maps System.Any_Priority to a POSIX priority.
+ -- Maps System.Any_Priority to a POSIX priority
-------------
-- Process --
@@ -273,6 +274,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
Ada.Unchecked_Conversion (System.Address, Thread_Body);
@@ -453,12 +455,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 (0 .. 127) of unsigned_char;