-- S p e c --
-- --
-- Copyright (C) 1991-1994, Florida State University --
--- Copyright (C) 1995-2005, Free Software Foundation, Inc. --
+-- Copyright (C) 1995-2007, Free Software Foundation, Inc. --
-- --
-- GNARL 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- --
-- 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 GNARL; see file COPYING. If not, write --
--- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
--- MA 02111-1307, USA. --
+-- 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, --
with Interfaces.C;
with Interfaces.C.Strings;
-with Unchecked_Conversion;
+with Ada.Unchecked_Conversion;
package System.OS_Interface is
-pragma Preelaborate;
+ pragma Preelaborate;
pragma Linker_Options ("-mthreads");
subtype PSZ is Interfaces.C.Strings.chars_ptr;
subtype PCHAR is Interfaces.C.Strings.chars_ptr;
+
subtype PVOID is System.Address;
Null_Void : constant PVOID := System.Null_Address;
NO_ERROR : constant := 0;
FUNC_ERR : constant := -1;
+ ------------------------
+ -- System Information --
+ ------------------------
+
+ type SYSTEM_INFO is record
+ dwOemId : DWORD;
+ dwPageSize : DWORD;
+ lpMinimumApplicationAddress : PVOID;
+ lpMaximumApplicationAddress : PVOID;
+ dwActiveProcessorMask : DWORD;
+ dwNumberOfProcessors : DWORD;
+ dwProcessorType : DWORD;
+ dwAllocationGranularity : DWORD;
+ dwReserved : DWORD;
+ end record;
+
+ procedure GetSystemInfo (SI : access SYSTEM_INFO);
+ pragma Import (Stdcall, GetSystemInfo, "GetSystemInfo");
+
-------------
-- Signals --
-------------
function (arg : System.Address) return System.Address;
function Thread_Body_Access is new
- Unchecked_Conversion (System.Address, Thread_Body);
+ Ada.Unchecked_Conversion (System.Address, Thread_Body);
procedure SwitchToThread;
pragma Import (Stdcall, SwitchToThread, "SwitchToThread");
+ function GetThreadTimes
+ (hThread : HANDLE;
+ lpCreationTime : access Long_Long_Integer;
+ lpExitTime : access Long_Long_Integer;
+ lpKernelTime : access Long_Long_Integer;
+ lpUserTime : access Long_Long_Integer) return BOOL;
+ pragma Import (Stdcall, GetThreadTimes, "GetThreadTimes");
+
-----------------------
-- Critical sections --
-----------------------
-- Thread Creation, Activation, Suspension And Termination --
-------------------------------------------------------------
+ subtype ProcessorId is DWORD;
+
type PTHREAD_START_ROUTINE is access function
(pThreadParameter : PVOID) return DWORD;
pragma Convention (Stdcall, PTHREAD_START_ROUTINE);
function To_PTHREAD_START_ROUTINE is new
- Unchecked_Conversion (System.Address, PTHREAD_START_ROUTINE);
+ Ada.Unchecked_Conversion (System.Address, PTHREAD_START_ROUTINE);
type SECURITY_ATTRIBUTES is record
nLength : DWORD;
pThreadId : PDWORD) return HANDLE;
pragma Import (C, BeginThreadEx, "_beginthreadex");
- Debug_Process : constant := 16#00000001#;
- Debug_Only_This_Process : constant := 16#00000002#;
- Create_Suspended : constant := 16#00000004#;
- Detached_Process : constant := 16#00000008#;
- Create_New_Console : constant := 16#00000010#;
+ Debug_Process : constant := 16#00000001#;
+ Debug_Only_This_Process : constant := 16#00000002#;
+ Create_Suspended : constant := 16#00000004#;
+ Detached_Process : constant := 16#00000008#;
+ Create_New_Console : constant := 16#00000010#;
- Create_New_Process_Group : constant := 16#00000200#;
+ Create_New_Process_Group : constant := 16#00000200#;
- Create_No_window : constant := 16#08000000#;
+ Create_No_window : constant := 16#08000000#;
- Profile_User : constant := 16#10000000#;
- Profile_Kernel : constant := 16#20000000#;
- Profile_Server : constant := 16#40000000#;
+ Profile_User : constant := 16#10000000#;
+ Profile_Kernel : constant := 16#20000000#;
+ Profile_Server : constant := 16#40000000#;
+
+ Stack_Size_Param_Is_A_Reservation : constant := 16#00010000#;
function GetExitCodeThread
(hThread : HANDLE;
fAlertable : BOOL) return DWORD;
pragma Import (Stdcall, WaitForSingleObjectEx, "WaitForSingleObjectEx");
+ function SetThreadIdealProcessor
+ (hThread : HANDLE;
+ dwIdealProcessor : ProcessorId) return DWORD;
+ pragma Import (Stdcall, SetThreadIdealProcessor, "SetThreadIdealProcessor");
+
Wait_Infinite : constant := DWORD'Last;
WAIT_TIMEOUT : constant := 16#0000_0102#;
WAIT_FAILED : constant := 16#FFFF_FFFF#;