OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [posix/] [current/] [include/] [sys/] [time.h] - Blame information for rev 810

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      include/sys/time.h
4
//
5
//      
6
//
7
//==========================================================================
8
// ####BSDALTCOPYRIGHTBEGIN####                                             
9
// -------------------------------------------                              
10
// Portions of this software may have been derived from FreeBSD, OpenBSD,   
11
// or other sources, and if so are covered by the appropriate copyright     
12
// and license included herein.                                             
13
// -------------------------------------------                              
14
// ####BSDALTCOPYRIGHTEND####                                               
15
//==========================================================================
16
//#####DESCRIPTIONBEGIN####
17
//
18
// Author(s):    gthomas
19
// Contributors: gthomas
20
// Date:         2000-01-10
21
// Purpose:      
22
// Description:  
23
//              
24
//
25
//####DESCRIPTIONEND####
26
//
27
//==========================================================================
28
 
29
 
30
/*      $OpenBSD: time.h,v 1.9 1999/12/06 19:36:42 aaron Exp $  */
31
/*      $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $        */
32
 
33
/*
34
 * Copyright (c) 1982, 1986, 1993
35
 *      The Regents of the University of California.  All rights reserved.
36
 *
37
 * Redistribution and use in source and binary forms, with or without
38
 * modification, are permitted provided that the following conditions
39
 * are met:
40
 * 1. Redistributions of source code must retain the above copyright
41
 *    notice, this list of conditions and the following disclaimer.
42
 * 2. Redistributions in binary form must reproduce the above copyright
43
 *    notice, this list of conditions and the following disclaimer in the
44
 *    documentation and/or other materials provided with the distribution.
45
 * 3. All advertising materials mentioning features or use of this software
46
 *    must display the following acknowledgement:
47
 *      This product includes software developed by the University of
48
 *      California, Berkeley and its contributors.
49
 * 4. Neither the name of the University nor the names of its contributors
50
 *    may be used to endorse or promote products derived from this software
51
 *    without specific prior written permission.
52
 *
53
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63
 * SUCH DAMAGE.
64
 *
65
 *      @(#)time.h      8.2 (Berkeley) 7/10/94
66
 */
67
 
68
#ifndef _SYS_TIME_H_
69
#define _SYS_TIME_H_
70
 
71
#ifdef __cplusplus
72
extern "C" {
73
#endif
74
 
75
#include <sys/types.h>
76
#include <time.h>
77
 
78
/*
79
 * Structure returned by gettimeofday(2) system call,
80
 * and used in other calls.
81
 */
82
struct timeval {
83
        long    tv_sec;         /* seconds */
84
        long    tv_usec;        /* and microseconds */
85
};
86
 
87
 
88
#define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
89
        (ts)->tv_sec = (tv)->tv_sec;                                    \
90
        (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
91
}
92
#define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
93
        (tv)->tv_sec = (ts)->tv_sec;                                    \
94
        (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
95
}
96
 
97
struct timezone {
98
        int     tz_minuteswest; /* minutes west of Greenwich */
99
        int     tz_dsttime;     /* type of dst correction */
100
};
101
 
102
#define DST_NONE        0        /* not on dst */
103
#define DST_USA         1       /* USA style dst */
104
#define DST_AUST        2       /* Australian style dst */
105
#define DST_WET         3       /* Western European dst */
106
#define DST_MET         4       /* Middle European dst */
107
#define DST_EET         5       /* Eastern European dst */
108
#define DST_CAN         6       /* Canada */
109
 
110
/* Operations on timevals. */
111
#define timerclear(tvp)         (tvp)->tv_sec = (tvp)->tv_usec = 0
112
#define timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
113
#define timercmp(tvp, uvp, cmp)                                         \
114
        (((tvp)->tv_sec == (uvp)->tv_sec) ?                             \
115
            ((tvp)->tv_usec cmp (uvp)->tv_usec) :                       \
116
            ((tvp)->tv_sec cmp (uvp)->tv_sec))
117
#define timeradd(tvp, uvp, vvp)                                         \
118
        do {                                                            \
119
                (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;          \
120
                (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;       \
121
                if ((vvp)->tv_usec >= 1000000) {                        \
122
                        (vvp)->tv_sec++;                                \
123
                        (vvp)->tv_usec -= 1000000;                      \
124
                }                                                       \
125
        } while (0)
126
#define timersub(tvp, uvp, vvp)                                         \
127
        do {                                                            \
128
                (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
129
                (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
130
                if ((vvp)->tv_usec < 0) {                                \
131
                        (vvp)->tv_sec--;                                \
132
                        (vvp)->tv_usec += 1000000;                      \
133
                }                                                       \
134
        } while (0)
135
 
136
/* Operations on timespecs. */
137
#define timespecclear(tsp)              (tsp)->tv_sec = (tsp)->tv_nsec = 0
138
#define timespecisset(tsp)              ((tsp)->tv_sec || (tsp)->tv_nsec)
139
#define timespeccmp(tsp, usp, cmp)                                      \
140
        (((tsp)->tv_sec == (usp)->tv_sec) ?                             \
141
            ((tsp)->tv_nsec cmp (usp)->tv_nsec) :                       \
142
            ((tsp)->tv_sec cmp (usp)->tv_sec))
143
#define timespecadd(tsp, usp, vsp)                                      \
144
        do {                                                            \
145
                (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;          \
146
                (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;       \
147
                if ((vsp)->tv_nsec >= 1000000000L) {                    \
148
                        (vsp)->tv_sec++;                                \
149
                        (vsp)->tv_nsec -= 1000000000L;                  \
150
                }                                                       \
151
        } while (0)
152
#define timespecsub(tsp, usp, vsp)                                      \
153
        do {                                                            \
154
                (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;          \
155
                (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;       \
156
                if ((vsp)->tv_nsec < 0) {                                \
157
                        (vsp)->tv_sec--;                                \
158
                        (vsp)->tv_nsec += 1000000000L;                  \
159
                }                                                       \
160
        } while (0)
161
 
162
 
163
int     gettimeofday(struct timeval *, struct timezone *);
164
 
165
#ifdef __cplusplus
166
}
167
#endif
168
 
169
 
170
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.