home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / ada / gnat-3.05- / gnat-3 / gnat-3.05-i486-linux-elf-bin / rts / 2ntcmasp.adb < prev    next >
Encoding:
Text File  |  1996-06-07  |  4.1 KB  |  90 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --  S Y S T E M . T A S K _ C L O C K . M A C H I N E _ S P E C I F I C S   --
  6. --                                                                          --
  7. --                                  B o d y                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.2 $                             --
  10. --                                                                          --
  11. --     Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc.     --
  12. --                                                                          --
  13. -- GNARL is free software; you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNARL; see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNARL was developed by the GNARL team at Florida State University. It is --
  32. -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
  33. -- State University (http://www.gnat.com).                                  --
  34. --                                                                          --
  35. ------------------------------------------------------------------------------
  36.  
  37. --  This implemetation is a version where no tasking supports provided.
  38.  
  39. with Interfaces.C; use Interfaces.C;
  40.  
  41. package body System.Task_Clock.Machine_Specifics is
  42.  
  43.    -----------
  44.    -- Clock --
  45.    -----------
  46.  
  47.    type Microseconds is new long;
  48.  
  49.    Microseconds_Per_Second : Microseconds := 10#1#E6;
  50.  
  51.    subtype Fractional_Second is Microseconds range
  52.      0 .. Microseconds_Per_Second - 1;
  53.    --  This is dependent on the stdtypes.h header file.
  54.  
  55.    type time_t is new int;
  56.  
  57.    type timespec is record
  58.       tv_sec : time_t;
  59.       tv_usec : Fractional_Second;
  60.    end record;
  61.  
  62.    type timezone is record
  63.       tz_minuteswest : int;   -- of Greenwich
  64.       tz_dsttime : int;       -- type of dst correction to apply
  65.    end record;
  66.  
  67.    function gettimeofday
  68.      (tp : access timespec;
  69.       tzp : access timezone)
  70.       return int;
  71.    pragma Import (C, gettimeofday);
  72.  
  73.    function Clock return Stimespec is
  74.       Now    : aliased timespec;
  75.       Result : int;
  76.  
  77.    begin
  78.       Result := gettimeofday (Now'Access, null);
  79.       return
  80.           Stimespec_Sec_Unit * Stimespec (Now.tv_sec) +
  81.           Stimespec (Now.tv_usec) * (Stimespec_Sec_Unit /
  82.             Stimespec (Microseconds_Per_Second));
  83.    end Clock;
  84.  
  85. begin
  86.    Stimespec_Ticks := Time_Of (0, 1000000);
  87.    --  Sun os 4.1 has clock resolution of 10ms.
  88.    --  This may work for other Solaris???
  89. end System.Task_Clock.Machine_Specifics;
  90.