home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / mach / time_value.h < prev    next >
C/C++ Source or Header  |  1992-07-29  |  2KB  |  67 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1989 Carnegie-Mellon University
  4.  * Copyright (c) 1988 Carnegie-Mellon University
  5.  * Copyright (c) 1987 Carnegie-Mellon University
  6.  * All rights reserved.  The CMU software License Agreement specifies
  7.  * the terms and conditions for use and redistribution.
  8.  */
  9. /*
  10.  * HISTORY
  11.  * $Log:    time_value.h,v $
  12.  * Revision 2.5  89/03/09  20:24:28  rpd
  13.  *     More cleanup.
  14.  * 
  15.  * Revision 2.4  89/02/25  18:41:34  gm0w
  16.  *     Changes for cleanup.
  17.  * 
  18.  * Revision 2.3  89/02/07  00:53:58  mwyoung
  19.  * Relocated from sys/time_value.h
  20.  * 
  21.  * Revision 2.2  89/01/31  01:21:58  rpd
  22.  *     TIME_MICROS_MAX should be 1 Million, not 10 Million.
  23.  *     [88/10/12            dlb]
  24.  * 
  25.  *  4-Jan-88  David Golub (dbg) at Carnegie-Mellon University
  26.  *    Created.
  27.  *
  28.  */
  29.  
  30. #ifndef    _MACH_TIME_VALUE_H_
  31. #define _MACH_TIME_VALUE_H_
  32.  
  33. /*
  34.  *    Time value returned by kernel.
  35.  */
  36.  
  37. struct time_value {
  38.     long    seconds;
  39.     long    microseconds;
  40. };
  41. typedef    struct time_value    time_value_t;
  42.  
  43. /*
  44.  *    Macros to manipulate time values.  Assume that time values
  45.  *    are normalized (microseconds <= 999999).
  46.  */
  47. #define    TIME_MICROS_MAX    (1000000)
  48.  
  49. #define    time_value_add_usec(val, micros)    {    \
  50.     if (((val)->microseconds += (micros))        \
  51.         >= TIME_MICROS_MAX) {            \
  52.         (val)->microseconds -= TIME_MICROS_MAX;    \
  53.         (val)->seconds++;                \
  54.     }                        \
  55. }
  56.  
  57. #define    time_value_add(result, addend)        {        \
  58.     (result)->microseconds += (addend)->microseconds;    \
  59.     (result)->seconds += (addend)->seconds;            \
  60.     if ((result)->microseconds >= TIME_MICROS_MAX) {    \
  61.         (result)->microseconds -= TIME_MICROS_MAX;        \
  62.         (result)->seconds++;                \
  63.     }                            \
  64. }
  65.  
  66. #endif    _MACH_TIME_VALUE_H_
  67.