summaryrefslogtreecommitdiffstats
path: root/c/src/exec/posix/src/time.c
blob: 58e8fafb106ec89dab110591bba0702ed24f222f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
 *  $Id$
 */

#include <time.h>

#include <rtems/system.h>
#include <rtems/score/tod.h>

/*
 *  Seconds from January 1, 1970 to January 1, 1988.  Used to account for
 *  differences between POSIX API and RTEMS core.
 */

#define POSIX_TIME_SECONDS_1970_THROUGH_1988 \
  (((1987 - 1970 + 1)  * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
  (4 * TOD_SECONDS_PER_DAY))

/*
 *  _POSIX_Time_Spec_to_interval
 */

Watchdog_Interval _POSIX_Time_Spec_to_interval(
  const struct timespec *time
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  4.5.1 Get System Time, P1003.1b-1993, p. 91
 */

time_t time(
  time_t   *tloc
)
{
  time_t  seconds_since_epoch;

  if ( !_TOD_Is_set() ) {
    /* XXX set errno */
    return -1;
  }

  /*
   *  Internally the RTEMS epoch is 1988.  This must be taken into account.
   */

  seconds_since_epoch = _TOD_Seconds_since_epoch;
     
  seconds_since_epoch += POSIX_TIME_SECONDS_1970_THROUGH_1988;

  if ( tloc )
    *tloc = seconds_since_epoch;

  return seconds_since_epoch;
}

/*
 *  14.2.1 Clocks, P1003.1b-1993, p. 263
 */

int clock_settime(
  clockid_t              clock_id,
  const struct timespec *tp
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  14.2.1 Clocks, P1003.1b-1993, p. 263
 */

int clock_gettime(
  clockid_t        clock_id,
  struct timespec *tp
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  14.2.1 Clocks, P1003.1b-1993, p. 263
 */

int clock_getres(
  clockid_t        clock_id,
  struct timespec *res
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  14.2.2 Create a Per-Process Timer, P1003.1b-1993, p. 264
 */

int timer_create(
  clockid_t        clock_id,
  struct sigevent *evp,
  timer_t         *timerid
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  14.2.3 Delete a Per_process Timer, P1003.1b-1993, p. 266
 */

int timer_delete(
  timer_t timerid
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  14.2.4 Per-Process Timers, P1003.1b-1993, p. 267
 */

int timer_settime(
  timer_t                  timerid,
  int                      flags,
  const struct itimerspec *value,
  struct itimerspec       *ovalue
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  14.2.4 Per-Process Timers, P1003.1b-1993, p. 267
 */

int timer_gettime(
  timer_t            timerid,
  struct itimerspec *value
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  14.2.4 Per-Process Timers, P1003.1b-1993, p. 267
 */

int timer_getoverrun(
  timer_t   timerid
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  14.2.5 High Resolution Sleep, P1003.1b-1993, p. 269
 */

int nanosleep(
  const struct timespec  *rqtp,
  struct timespec        *rmtp
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  20.1.3 Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55
 */

int clock_getcpuclockid(
  pid_t      pid,
  clockid_t *clock_id
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  20.1.5 CPU-time Clock Attribute Access, P1003.4b/D8, p. 58
 */

int clock_setenable_attr(
  clockid_t    clock_id,
  int          attr
)
{
  return POSIX_NOT_IMPLEMENTED();
}

/*
 *  20.1.5 CPU-time Clock Attribute Access, P1003.4b/D8, p. 58
 */

int clock_getenable_attr(
  clockid_t    clock_id,
  int         *attr
)
{
  return POSIX_NOT_IMPLEMENTED();
}