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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [tcpip/] [current/] [include/] [sys/] [time.h] - Blame information for rev 838

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 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
#include <sys/types.h>
72
#include <time.h>
73
 
74
#if 0 //ndef __time_t_defined
75
typedef int time_t;
76
# define __time_t_defined
77
#endif
78
 
79
#if 0
80
 
81
/*
82
 * Structure returned by gettimeofday(2) system call,
83
 * and used in other calls.
84
 */
85
struct timeval {
86
        long    tv_sec;         /* seconds */
87
        long    tv_usec;        /* and microseconds */
88
};
89
 
90
#endif
91
 
92
#if 0
93
/*
94
 * Structure defined by POSIX.1b to be like a timeval.
95
 */
96
struct timespec {
97
        time_t  tv_sec;         /* seconds */
98
        long    tv_nsec;        /* and nanoseconds */
99
};
100
#endif
101
 
102
#define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
103
        (ts)->tv_sec = (tv)->tv_sec;                                    \
104
        (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
105
}
106
#define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
107
        (tv)->tv_sec = (ts)->tv_sec;                                    \
108
        (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
109
}
110
 
111
struct timezone {
112
        int     tz_minuteswest; /* minutes west of Greenwich */
113
        int     tz_dsttime;     /* type of dst correction */
114
};
115
#define DST_NONE        0        /* not on dst */
116
#define DST_USA         1       /* USA style dst */
117
#define DST_AUST        2       /* Australian style dst */
118
#define DST_WET         3       /* Western European dst */
119
#define DST_MET         4       /* Middle European dst */
120
#define DST_EET         5       /* Eastern European dst */
121
#define DST_CAN         6       /* Canada */
122
 
123
/* Operations on timevals. */
124
#define timerclear(tvp)         (tvp)->tv_sec = (tvp)->tv_usec = 0
125
#define timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
126
#define timercmp(tvp, uvp, cmp)                                         \
127
        (((tvp)->tv_sec == (uvp)->tv_sec) ?                             \
128
            ((tvp)->tv_usec cmp (uvp)->tv_usec) :                       \
129
            ((tvp)->tv_sec cmp (uvp)->tv_sec))
130
#define timeradd(tvp, uvp, vvp)                                         \
131
        do {                                                            \
132
                (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;          \
133
                (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;       \
134
                if ((vvp)->tv_usec >= 1000000) {                        \
135
                        (vvp)->tv_sec++;                                \
136
                        (vvp)->tv_usec -= 1000000;                      \
137
                }                                                       \
138
        } while (0)
139
#define timersub(tvp, uvp, vvp)                                         \
140
        do {                                                            \
141
                (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
142
                (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
143
                if ((vvp)->tv_usec < 0) {                                \
144
                        (vvp)->tv_sec--;                                \
145
                        (vvp)->tv_usec += 1000000;                      \
146
                }                                                       \
147
        } while (0)
148
 
149
/* Operations on timespecs. */
150
#define timespecclear(tsp)              (tsp)->tv_sec = (tsp)->tv_nsec = 0
151
#define timespecisset(tsp)              ((tsp)->tv_sec || (tsp)->tv_nsec)
152
#define timespeccmp(tsp, usp, cmp)                                      \
153
        (((tsp)->tv_sec == (usp)->tv_sec) ?                             \
154
            ((tsp)->tv_nsec cmp (usp)->tv_nsec) :                       \
155
            ((tsp)->tv_sec cmp (usp)->tv_sec))
156
#define timespecadd(tsp, usp, vsp)                                      \
157
        do {                                                            \
158
                (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;          \
159
                (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;       \
160
                if ((vsp)->tv_nsec >= 1000000000L) {                    \
161
                        (vsp)->tv_sec++;                                \
162
                        (vsp)->tv_nsec -= 1000000000L;                  \
163
                }                                                       \
164
        } while (0)
165
#define timespecsub(tsp, usp, vsp)                                      \
166
        do {                                                            \
167
                (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;          \
168
                (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;       \
169
                if ((vsp)->tv_nsec < 0) {                                \
170
                        (vsp)->tv_sec--;                                \
171
                        (vsp)->tv_nsec += 1000000000L;                  \
172
                }                                                       \
173
        } while (0)
174
 
175
/*
176
 * Names of the interval timers, and structure
177
 * defining a timer setting.
178
 */
179
#define ITIMER_REAL     0
180
#define ITIMER_VIRTUAL  1
181
#define ITIMER_PROF     2
182
 
183
struct  itimerval {
184
        struct  timeval it_interval;    /* timer interval */
185
        struct  timeval it_value;       /* current value */
186
};
187
 
188
/*
189
 * Getkerninfo clock information structure
190
 */
191
struct clockinfo {
192
        int     hz;             /* clock frequency */
193
        int     tick;           /* micro-seconds per hz tick */
194
        int     tickadj;        /* clock skew rate for adjtime() */
195
        int     stathz;         /* statistics clock frequency */
196
        int     profhz;         /* profiling clock frequency */
197
};
198
 
199
#define CLOCK_REALTIME  0
200
#define CLOCK_VIRTUAL   1
201
#define CLOCK_PROF      2
202
 
203
#define TIMER_RELTIME   0x0     /* relative timer */
204
#ifndef TIMER_ABSTIME
205
#define TIMER_ABSTIME   0x1     /* absolute timer */
206
#endif
207
 
208
#if defined(_KERNEL) || defined(_STANDALONE)
209
int     itimerfix __P((struct timeval *tv));
210
int     itimerdecr __P((struct itimerval *itp, int usec));
211
void    microtime __P((struct timeval *tv));
212
void    settime __P((struct timeval *tv));
213
#else /* !_KERNEL */
214
 
215
#ifndef __ECOS
216
#include <time.h>
217
#endif
218
 
219
#if 0 //ndef _POSIX_SOURCE
220
#include <sys/cdefs.h>
221
 
222
__BEGIN_DECLS
223
int     adjtime __P((const struct timeval *, struct timeval *));
224
int     clock_getres __P((clockid_t, struct timespec *));
225
int     clock_gettime __P((clockid_t, struct timespec *));
226
int     clock_settime __P((clockid_t, const struct timespec *));
227
int     futimes __P((int, const struct timeval *));
228
int     getitimer __P((int, struct itimerval *));
229
int     gettimeofday __P((struct timeval *, struct timezone *));
230
int     nanosleep __P((const struct timespec *, struct timespec *));
231
int     setitimer __P((int, const struct itimerval *, struct itimerval *));
232
int     settimeofday __P((const struct timeval *, const struct timezone *));
233
int     utimes __P((const char *, const struct timeval *));
234
__END_DECLS
235
#endif /* !POSIX */
236
 
237
#endif /* !_KERNEL */
238
 
239
#endif /* !_SYS_TIME_H_ */

powered by: WebSVN 2.1.0

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