Annotation of OSKit-Mach/include/mach/time_value.h, revision 1.1.1.1

1.1       root        1: /* 
                      2:  * Mach Operating System
                      3:  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
                      4:  * All Rights Reserved.
                      5:  * 
                      6:  * Permission to use, copy, modify and distribute this software and its
                      7:  * documentation is hereby granted, provided that both the copyright
                      8:  * notice and this permission notice appear in all copies of the
                      9:  * software, derivative works or modified versions, and any portions
                     10:  * thereof, and that both notices appear in supporting documentation.
                     11:  * 
                     12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     15:  * 
                     16:  * Carnegie Mellon requests users of this software to return to
                     17:  * 
                     18:  *  Software Distribution Coordinator  or  [email protected]
                     19:  *  School of Computer Science
                     20:  *  Carnegie Mellon University
                     21:  *  Pittsburgh PA 15213-3890
                     22:  * 
                     23:  * any improvements or extensions that they make and grant Carnegie Mellon
                     24:  * the rights to redistribute these changes.
                     25:  */
                     26: 
                     27: #ifndef        _MACH_TIME_VALUE_H_
                     28: #define        _MACH_TIME_VALUE_H_
                     29: 
                     30: #include <mach/machine/vm_types.h>
                     31: 
                     32: /*
                     33:  *     Time value returned by kernel.
                     34:  */
                     35: 
                     36: struct time_value {
                     37:        integer_t       seconds;
                     38:        integer_t       microseconds;
                     39: };
                     40: typedef        struct time_value       time_value_t;
                     41: 
                     42: /*
                     43:  *     Macros to manipulate time values.  Assume that time values
                     44:  *     are normalized (microseconds <= 999999).
                     45:  */
                     46: #define        TIME_MICROS_MAX (1000000)
                     47: 
                     48: #define        time_value_add_usec(val, micros)        {       \
                     49:        if (((val)->microseconds += (micros))           \
                     50:                >= TIME_MICROS_MAX) {                   \
                     51:            (val)->microseconds -= TIME_MICROS_MAX;     \
                     52:            (val)->seconds++;                           \
                     53:        }                                               \
                     54: }
                     55: 
                     56: #define        time_value_add(result, addend)          {               \
                     57:        (result)->microseconds += (addend)->microseconds;       \
                     58:        (result)->seconds += (addend)->seconds;                 \
                     59:        if ((result)->microseconds >= TIME_MICROS_MAX) {        \
                     60:            (result)->microseconds -= TIME_MICROS_MAX;          \
                     61:            (result)->seconds++;                                \
                     62:        }                                                       \
                     63: }
                     64: 
                     65: /*
                     66:  *     Time value available through the mapped-time interface.
                     67:  *     Read this mapped value with
                     68:  *             do {
                     69:  *                     secs = mtime->seconds;
                     70:  *                     usecs = mtime->microseconds;
                     71:  *             } while (secs != mtime->check_seconds);
                     72:  */
                     73: 
                     74: typedef struct mapped_time_value {
                     75:        integer_t seconds;
                     76:        integer_t microseconds;
                     77:        integer_t check_seconds;
                     78: } mapped_time_value_t;
                     79: 
                     80: #endif /* _MACH_TIME_VALUE_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.