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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [tcpip/] [v2_0/] [include/] [sys/] [time.h] - Blame information for rev 773

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      include/sys/time.h
4
//
5
//      
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
12
// Portions of this software may have been derived from OpenBSD or other sources,
13
// and are covered by the appropriate copyright disclaimers included herein.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-01-10
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
 
32
 
33
/*      $OpenBSD: time.h,v 1.9 1999/12/06 19:36:42 aaron Exp $  */
34
/*      $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $        */
35
 
36
/*
37
 * Copyright (c) 1982, 1986, 1993
38
 *      The Regents of the University of California.  All rights reserved.
39
 *
40
 * Redistribution and use in source and binary forms, with or without
41
 * modification, are permitted provided that the following conditions
42
 * are met:
43
 * 1. Redistributions of source code must retain the above copyright
44
 *    notice, this list of conditions and the following disclaimer.
45
 * 2. Redistributions in binary form must reproduce the above copyright
46
 *    notice, this list of conditions and the following disclaimer in the
47
 *    documentation and/or other materials provided with the distribution.
48
 * 3. All advertising materials mentioning features or use of this software
49
 *    must display the following acknowledgement:
50
 *      This product includes software developed by the University of
51
 *      California, Berkeley and its contributors.
52
 * 4. Neither the name of the University nor the names of its contributors
53
 *    may be used to endorse or promote products derived from this software
54
 *    without specific prior written permission.
55
 *
56
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66
 * SUCH DAMAGE.
67
 *
68
 *      @(#)time.h      8.2 (Berkeley) 7/10/94
69
 */
70
 
71
#ifndef _SYS_TIME_H_
72
#define _SYS_TIME_H_
73
 
74
#include <sys/types.h>
75
#include <time.h>
76
 
77
#if 0 //ndef __time_t_defined
78
typedef int time_t;
79
# define __time_t_defined
80
#endif
81
 
82
#if 0
83
 
84
/*
85
 * Structure returned by gettimeofday(2) system call,
86
 * and used in other calls.
87
 */
88
struct timeval {
89
        long    tv_sec;         /* seconds */
90
        long    tv_usec;        /* and microseconds */
91
};
92
 
93
#endif
94
 
95
#if 0
96
/*
97
 * Structure defined by POSIX.1b to be like a timeval.
98
 */
99
struct timespec {
100
        time_t  tv_sec;         /* seconds */
101
        long    tv_nsec;        /* and nanoseconds */
102
};
103
#endif
104
 
105
#define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
106
        (ts)->tv_sec = (tv)->tv_sec;                                    \
107
        (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
108
}
109
#define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
110
        (tv)->tv_sec = (ts)->tv_sec;                                    \
111
        (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
112
}
113
 
114
struct timezone {
115
        int     tz_minuteswest; /* minutes west of Greenwich */
116
        int     tz_dsttime;     /* type of dst correction */
117
};
118
#define DST_NONE        0        /* not on dst */
119
#define DST_USA         1       /* USA style dst */
120
#define DST_AUST        2       /* Australian style dst */
121
#define DST_WET         3       /* Western European dst */
122
#define DST_MET         4       /* Middle European dst */
123
#define DST_EET         5       /* Eastern European dst */
124
#define DST_CAN         6       /* Canada */
125
 
126
/* Operations on timevals. */
127
#define timerclear(tvp)         (tvp)->tv_sec = (tvp)->tv_usec = 0
128
#define timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
129
#define timercmp(tvp, uvp, cmp)                                         \
130
        (((tvp)->tv_sec == (uvp)->tv_sec) ?                             \
131
            ((tvp)->tv_usec cmp (uvp)->tv_usec) :                       \
132
            ((tvp)->tv_sec cmp (uvp)->tv_sec))
133
#define timeradd(tvp, uvp, vvp)                                         \
134
        do {                                                            \
135
                (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;          \
136
                (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;       \
137
                if ((vvp)->tv_usec >= 1000000) {                        \
138
                        (vvp)->tv_sec++;                                \
139
                        (vvp)->tv_usec -= 1000000;                      \
140
                }                                                       \
141
        } while (0)
142
#define timersub(tvp, uvp, vvp)                                         \
143
        do {                                                            \
144
                (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
145
                (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
146
                if ((vvp)->tv_usec < 0) {                                \
147
                        (vvp)->tv_sec--;                                \
148
                        (vvp)->tv_usec += 1000000;                      \
149
                }                                                       \
150
        } while (0)
151
 
152
/* Operations on timespecs. */
153
#define timespecclear(tsp)              (tsp)->tv_sec = (tsp)->tv_nsec = 0
154
#define timespecisset(tsp)              ((tsp)->tv_sec || (tsp)->tv_nsec)
155
#define timespeccmp(tsp, usp, cmp)                                      \
156
        (((tsp)->tv_sec == (usp)->tv_sec) ?                             \
157
            ((tsp)->tv_nsec cmp (usp)->tv_nsec) :                       \
158
            ((tsp)->tv_sec cmp (usp)->tv_sec))
159
#define timespecadd(tsp, usp, vsp)                                      \
160
        do {                                                            \
161
                (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;          \
162
                (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;       \
163
                if ((vsp)->tv_nsec >= 1000000000L) {                    \
164
                        (vsp)->tv_sec++;                                \
165
                        (vsp)->tv_nsec -= 1000000000L;                  \
166
                }                                                       \
167
        } while (0)
168
#define timespecsub(tsp, usp, vsp)                                      \
169
        do {                                                            \
170
                (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;          \
171
                (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;       \
172
                if ((vsp)->tv_nsec < 0) {                                \
173
                        (vsp)->tv_sec--;                                \
174
                        (vsp)->tv_nsec += 1000000000L;                  \
175
                }                                                       \
176
        } while (0)
177
 
178
/*
179
 * Names of the interval timers, and structure
180
 * defining a timer setting.
181
 */
182
#define ITIMER_REAL     0
183
#define ITIMER_VIRTUAL  1
184
#define ITIMER_PROF     2
185
 
186
struct  itimerval {
187
        struct  timeval it_interval;    /* timer interval */
188
        struct  timeval it_value;       /* current value */
189
};
190
 
191
/*
192
 * Getkerninfo clock information structure
193
 */
194
struct clockinfo {
195
        int     hz;             /* clock frequency */
196
        int     tick;           /* micro-seconds per hz tick */
197
        int     tickadj;        /* clock skew rate for adjtime() */
198
        int     stathz;         /* statistics clock frequency */
199
        int     profhz;         /* profiling clock frequency */
200
};
201
 
202
#define CLOCK_REALTIME  0
203
#define CLOCK_VIRTUAL   1
204
#define CLOCK_PROF      2
205
 
206
#define TIMER_RELTIME   0x0     /* relative timer */
207
#ifndef TIMER_ABSTIME
208
#define TIMER_ABSTIME   0x1     /* absolute timer */
209
#endif
210
 
211
#if defined(_KERNEL) || defined(_STANDALONE)
212
int     itimerfix __P((struct timeval *tv));
213
int     itimerdecr __P((struct itimerval *itp, int usec));
214
void    microtime __P((struct timeval *tv));
215
void    settime __P((struct timeval *tv));
216
#else /* !_KERNEL */
217
 
218
#ifndef __ECOS
219
#include <time.h>
220
#endif
221
 
222
#if 0 //ndef _POSIX_SOURCE
223
#include <sys/cdefs.h>
224
 
225
__BEGIN_DECLS
226
int     adjtime __P((const struct timeval *, struct timeval *));
227
int     clock_getres __P((clockid_t, struct timespec *));
228
int     clock_gettime __P((clockid_t, struct timespec *));
229
int     clock_settime __P((clockid_t, const struct timespec *));
230
int     futimes __P((int, const struct timeval *));
231
int     getitimer __P((int, struct itimerval *));
232
int     gettimeofday __P((struct timeval *, struct timezone *));
233
int     nanosleep __P((const struct timespec *, struct timespec *));
234
int     setitimer __P((int, const struct itimerval *, struct itimerval *));
235
int     settimeofday __P((const struct timeval *, const struct timezone *));
236
int     utimes __P((const char *, const struct timeval *));
237
__END_DECLS
238
#endif /* !POSIX */
239
 
240
#endif /* !_KERNEL */
241
 
242
#endif /* !_SYS_TIME_H_ */

powered by: WebSVN 2.1.0

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