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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [newlib/] [newlib/] [libc/] [sys/] [rtems/] [sys/] [time.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/*
2 59 joel
 *  $Id: time.h,v 1.2 2000-09-05 17:10:20 joel Exp $
3 39 lampret
 */
4
 
5
#include <sys/types.h>
6
 
7
#ifndef __POSIX_SYS_TIME_h
8
#define __POSIX_SYS_TIME_h
9
 
10 56 joel
#ifdef __cplusplus
11
extern "C" {
12
#endif
13
 
14 39 lampret
/*
15
 *  Get the CPU dependent types for clock_t and time_t
16
 *
17
 *  NOTE:  These must be visible by including <time.h>.
18
 */
19
 
20
/* Get _CLOCK_T_ and _TIME_T_.  */
21
#include <machine/types.h>
22
 
23
#ifndef __clock_t_defined
24
typedef _CLOCK_T_ clock_t;
25
#define __clock_t_defined
26
#endif
27
 
28
#ifndef __time_t_defined
29
typedef _TIME_T_ time_t;
30
#define __time_t_defined
31
#endif
32
 
33
/*
34
 *  14.1.1 Time Value Specification Structures, P1003.1b-1993, p. 261
35
 */
36
 
37
struct timespec {
38
  time_t  tv_sec;   /* Seconds */
39
  long    tv_nsec;  /* Nanoseconds */
40
};
41
 
42
struct itimerspec {
43
  struct timespec  it_interval;  /* Timer period */
44
  struct timespec  it_value;     /* Timer expiration */
45
};
46
 
47
/* XXX should really be ifdef'ed */
48
 
49
/*
50
 *  BSD based stuff
51
 */
52
 
53
struct timezone {
54
  int tz_minuteswest;
55
  int tz_dsttime;
56
};
57
 
58
struct timeval {
59
  int tv_sec;
60
  int tv_usec;
61
};
62
 
63
int gettimeofday(
64
  struct timeval  *tp,
65
  struct timezone *tzp
66
);
67
 
68 59 joel
/* Convenience macros for operations on timevals.
69
   NOTE: `timercmp' does not work for >= or <=.  */
70
#define timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
71
#define timerclear(tvp)         ((tvp)->tv_sec = (tvp)->tv_usec = 0)
72
#define timercmp(a, b, CMP)                                                   \
73
  (((a)->tv_sec == (b)->tv_sec) ?                                             \
74
   ((a)->tv_usec CMP (b)->tv_usec) :                                          \
75
   ((a)->tv_sec CMP (b)->tv_sec))
76
#define timeradd(a, b, result)                                                \
77
  do {                                                                        \
78
    (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;                             \
79
    (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;                          \
80
    if ((result)->tv_usec >= 1000000)                                         \
81
      {                                                                       \
82
        ++(result)->tv_sec;                                                   \
83
        (result)->tv_usec -= 1000000;                                         \
84
      }                                                                       \
85
  } while (0)
86
#define timersub(a, b, result)                                                \
87
  do {                                                                        \
88
    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;                             \
89
    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;                          \
90
    if ((result)->tv_usec < 0) {                                       \
91
      --(result)->tv_sec;                                                     \
92
      (result)->tv_usec += 1000000;                                           \
93
    }                                                                         \
94
  } while (0)
95 56 joel
#ifdef __cplusplus
96
}
97
#endif 
98
 
99 39 lampret
#endif
100
/* end of include */

powered by: WebSVN 2.1.0

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