home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / packages / win32ada / data.z / win32-stdlib.adb < prev    next >
Encoding:
Text File  |  1995-12-27  |  2.2 KB  |  62 lines

  1. -- $Source: /home/harp/1/proto/monoBANK/winnt/win32-stdlib.adb,v $ 
  2. -- $Revision: 1.5 $ $Date: 95/02/02 15:57:17 $ $Author: mg $ 
  3. -------------------------------------------------------------------------------
  4. --
  5. -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS FURNISHED "AS IS" WITHOUT 
  6. -- WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
  7. -- TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR 
  8. -- PURPOSE.  The user assumes the entire risk as to the accuracy and the 
  9. -- use of this file.
  10. --
  11. -- Copyright (c) Intermetrics, Inc. 1995
  12. -- Royalty-free, unlimited, worldwide, non-exclusive use, modification, 
  13. -- reproduction and further distribution of this file is permitted.
  14. --
  15. -------------------------------------------------------------------------------
  16.  
  17.  
  18. with Ada.Unchecked_Conversion;
  19. with System;
  20. with Win32.PerThread;
  21.  
  22. package body Win32.Stdlib is
  23.     
  24.     function Maximum(A, B: T) return T is
  25.     begin
  26.       if A > B then return A; else return B; end if;
  27.     end Maximum;
  28.  
  29.     function Minimum(A, B: T) return T is
  30.     begin
  31.       if A < B then return A; else return B; end if;
  32.     end Minimum;
  33.  
  34.     use type Win32.INT;        -- to get ">"
  35.     function Mx is new Maximum(Win32.INT, ">");
  36.     function Max(A, B: Win32.INT) return Win32.INT renames Mx;
  37.  
  38.     function Mn is new Minimum(Win32.INT, "<");
  39.     function Min(A, B: Win32.INT) return Win32.INT renames Mn;
  40.  
  41.     -- If necessary someone could look at this code, and write a
  42.     -- procedure that gets the address and then *sets* the code
  43.     -- instead of getting it.  I don't know if this is useful.
  44.  
  45.     function errno return Win32.INT is
  46.         function To_PINT is new Ada.Unchecked_Conversion (
  47.             System.Address, Win32.PINT);
  48.     begin
  49.         return To_PINT(Win32.PerThread.Get_Address(Win32.PerThread.Errno)).all;
  50.     end errno;
  51.  
  52.     function doserrno return Win32.ULONG is
  53.         type PULONG is access all Win32.ULONG;
  54.         function To_PULONG is new Ada.Unchecked_Conversion (
  55.             System.Address, Win32.PULONG);
  56.     begin
  57.         return To_PULONG(Win32.PerThread.Get_Address(
  58.              Win32.PerThread.Doserrno)).all;
  59.     end doserrno;
  60.  
  61. end Win32.Stdlib;
  62.