home *** CD-ROM | disk | FTP | other *** search
- -- $Source: /home/harp/1/proto/monoBANK/winnt/win32-stdlib.adb,v $
- -- $Revision: 1.5 $ $Date: 95/02/02 15:57:17 $ $Author: mg $
- -------------------------------------------------------------------------------
- --
- -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS FURNISHED "AS IS" WITHOUT
- -- WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- -- TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
- -- PURPOSE. The user assumes the entire risk as to the accuracy and the
- -- use of this file.
- --
- -- Copyright (c) Intermetrics, Inc. 1995
- -- Royalty-free, unlimited, worldwide, non-exclusive use, modification,
- -- reproduction and further distribution of this file is permitted.
- --
- -------------------------------------------------------------------------------
-
-
- with Ada.Unchecked_Conversion;
- with System;
- with Win32.PerThread;
-
- package body Win32.Stdlib is
-
- function Maximum(A, B: T) return T is
- begin
- if A > B then return A; else return B; end if;
- end Maximum;
-
- function Minimum(A, B: T) return T is
- begin
- if A < B then return A; else return B; end if;
- end Minimum;
-
- use type Win32.INT; -- to get ">"
- function Mx is new Maximum(Win32.INT, ">");
- function Max(A, B: Win32.INT) return Win32.INT renames Mx;
-
- function Mn is new Minimum(Win32.INT, "<");
- function Min(A, B: Win32.INT) return Win32.INT renames Mn;
-
- -- If necessary someone could look at this code, and write a
- -- procedure that gets the address and then *sets* the code
- -- instead of getting it. I don't know if this is useful.
-
- function errno return Win32.INT is
- function To_PINT is new Ada.Unchecked_Conversion (
- System.Address, Win32.PINT);
- begin
- return To_PINT(Win32.PerThread.Get_Address(Win32.PerThread.Errno)).all;
- end errno;
-
- function doserrno return Win32.ULONG is
- type PULONG is access all Win32.ULONG;
- function To_PULONG is new Ada.Unchecked_Conversion (
- System.Address, Win32.PULONG);
- begin
- return To_PULONG(Win32.PerThread.Get_Address(
- Win32.PerThread.Doserrno)).all;
- end doserrno;
-
- end Win32.Stdlib;
-