aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/s-tasinf-linux.adb
diff options
context:
space:
mode:
authorPascal Obry <obry@adacore.com>2007-12-13 11:18:44 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2007-12-13 11:18:44 +0100
commitb41ab480565d08ba5535f219e9f607e15d9c47e0 (patch)
treeaab7a215c62fc85b658d90381374889f961afcaa /gcc/ada/s-tasinf-linux.adb
parentaa4095c911de99a3f5bec44da96299ec8945f88a (diff)
downloadgcc-b41ab480565d08ba5535f219e9f607e15d9c47e0.zip
gcc-b41ab480565d08ba5535f219e9f607e15d9c47e0.tar.gz
gcc-b41ab480565d08ba5535f219e9f607e15d9c47e0.tar.bz2
adaint.c (__gnat_pthread_setaffinity_np): New routine.
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. From-SVN: r130812
Diffstat (limited to 'gcc/ada/s-tasinf-linux.adb')
-rw-r--r--gcc/ada/s-tasinf-linux.adb57
1 files changed, 57 insertions, 0 deletions
diff --git a/gcc/ada/s-tasinf-linux.adb b/gcc/ada/s-tasinf-linux.adb
new file mode 100644
index 0000000..0510a63
--- /dev/null
+++ b/gcc/ada/s-tasinf-linux.adb
@@ -0,0 +1,57 @@
+------------------------------------------------------------------------------
+-- --
+-- GNAT COMPILER COMPONENTS --
+-- --
+-- S Y S T E M . T A S K _ I N F O --
+-- --
+-- B o d y --
+-- --
+-- Copyright (C) 2007, Free Software Foundation, Inc. --
+-- --
+-- GNAT 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- --
+-- ware Foundation; either version 2, or (at your option) any later ver- --
+-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
+-- for more details. You should have received a copy of the GNU General --
+-- Public License distributed with GNAT; see file COPYING. If not, write --
+-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
+-- Boston, MA 02110-1301, USA. --
+-- --
+-- As a special exception, if other files instantiate generics from this --
+-- unit, or you link this unit with other files to produce an executable, --
+-- this unit does not by itself cause the resulting executable to be --
+-- covered by the GNU General Public License. This exception does not --
+-- however invalidate any other reasons why the executable file might be --
+-- covered by the GNU Public License. --
+-- --
+-- GNAT was originally developed by the GNAT team at New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc. --
+-- --
+------------------------------------------------------------------------------
+
+-- This is the GNU/Linux version of this module
+
+package body System.Task_Info is
+
+ N_CPU : Natural := 0;
+ pragma Atomic (N_CPU);
+ -- Cache CPU number. Use pragma Atomic to avoid a race condition when
+ -- setting N_CPU in Number_Of_Processors below.
+
+ --------------------------
+ -- Number_Of_Processors --
+ --------------------------
+
+ function Number_Of_Processors return Positive is
+ begin
+ if N_CPU = 0 then
+ N_CPU := Natural
+ (OS_Interface.sysconf (OS_Interface.SC_NPROCESSORS_ONLN));
+ end if;
+
+ return N_CPU;
+ end Number_Of_Processors;
+
+end System.Task_Info;