OSDN Git Service

2008-04-08 Hristian Kirtchev <kirtchev@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-tasinf-mingw.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                     S Y S T E M . T A S K _ I N F O                      --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --         Copyright (C) 2007-2008, Free Software Foundation, Inc.          --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This package contains the definitions and routines associated with the
35 --  implementation and use of the Task_Info pragma. It is specialized
36 --  appropriately for targets that make use of this pragma.
37
38 --  Note: the compiler generates direct calls to this interface, via Rtsfind.
39 --  Any changes to this interface may require corresponding compiler changes.
40
41 --  This unit may be used directly from an application program by providing
42 --  an appropriate WITH, and the interface can be expected to remain stable.
43
44 --  This is the Windows (native) version of this module
45
46 with System.Win32;
47
48 package System.Task_Info is
49    pragma Preelaborate;
50    pragma Elaborate_Body;
51    --  To ensure that a body is allowed
52
53    use type System.Win32.ProcessorId;
54
55    --  Windows provides a way to define the ideal processor to use for a given
56    --  thread. The ideal processor is not necessarily the one that will be used
57    --  by the OS but the OS will always try to schedule this thread to the
58    --  specified processor if it is available.
59
60    --  The Task_Info pragma:
61
62    --    pragma Task_Info (EXPRESSION);
63
64    --  allows the specification on a task by task basis of a value of type
65    --  System.Task_Info.Task_Info_Type to be passed to a task when it is
66    --  created. The specification of this type, and the effect on the task
67    --  that is created is target dependent.
68
69    --  The Task_Info pragma appears within a task definition (compare the
70    --  definition and implementation of pragma Priority). If no such pragma
71    --  appears, then the value Unspecified_Task_Info is passed. If a pragma
72    --  is present, then it supplies an alternative value. If the argument of
73    --  the pragma is a discriminant reference, then the value can be set on
74    --  a task by task basis by supplying the appropriate discriminant value.
75
76    --  Note that this means that the type used for Task_Info_Type must be
77    --  suitable for use as a discriminant (i.e. a scalar or access type).
78
79    -----------------------
80    -- Thread Attributes --
81    -----------------------
82
83    subtype CPU_Number is System.Win32.ProcessorId;
84
85    Any_CPU : constant CPU_Number := -1;
86
87    Invalid_CPU_Number : exception;
88    --  Raised when an invalid CPU number has been specified
89    --  i.e. CPU > Number_Of_Processors.
90
91    type Thread_Attributes is record
92       CPU : CPU_Number := Any_CPU;
93    end record;
94
95    Default_Thread_Attributes : constant Thread_Attributes := (others => <>);
96
97    type Task_Info_Type is access all Thread_Attributes;
98
99    Unspecified_Task_Info : constant Task_Info_Type := null;
100
101    function Number_Of_Processors return Positive;
102    --  Returns the number of processors on the running host
103
104 end System.Task_Info;