4.104.114.84.95
Last change
on this file since 35ee867 was
35ee867,
checked in by Joel Sherrill <joel.sherrill@…>, on 12/02/02 at 19:15:24
|
2002-12-02 Joel Sherrill <joel@…>
- include/rtems/posix/timer.h, src/keygetspecific.c,
src/posixtimespecsubtract.c, src/ptimer1.c, src/semunlink.c:
Added casts to eliminate warnings on 16-bit targets like the h8300.
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[9f95a19] | 1 | /* |
---|
| 2 | * $Id$ |
---|
| 3 | */ |
---|
| 4 | |
---|
[f42b726] | 5 | #if HAVE_CONFIG_H |
---|
| 6 | #include "config.h" |
---|
| 7 | #endif |
---|
| 8 | |
---|
[9f95a19] | 9 | #include <assert.h> |
---|
| 10 | #include <time.h> |
---|
| 11 | #include <errno.h> |
---|
| 12 | |
---|
| 13 | #include <rtems/system.h> |
---|
| 14 | #include <rtems/score/isr.h> |
---|
| 15 | #include <rtems/score/thread.h> |
---|
| 16 | #include <rtems/score/tod.h> |
---|
| 17 | |
---|
[188c82b] | 18 | #include <rtems/seterr.h> |
---|
[9f95a19] | 19 | #include <rtems/posix/time.h> |
---|
| 20 | |
---|
| 21 | /*PAGE |
---|
| 22 | * |
---|
| 23 | * _POSIX_Timespec_subtract |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | void _POSIX_Timespec_subtract( |
---|
| 27 | const struct timespec *the_start, |
---|
| 28 | const struct timespec *end, |
---|
| 29 | struct timespec *result |
---|
| 30 | ) |
---|
| 31 | { |
---|
| 32 | struct timespec start_struct = *the_start; |
---|
| 33 | struct timespec *start = &start_struct; |
---|
[35ee867] | 34 | unsigned32 nsecs_per_sec = TOD_NANOSECONDS_PER_SECOND; |
---|
[9f95a19] | 35 | |
---|
| 36 | if (end->tv_nsec < start->tv_nsec) { |
---|
| 37 | int seconds = (start->tv_nsec - end->tv_nsec) / nsecs_per_sec + 1; |
---|
| 38 | start->tv_nsec -= nsecs_per_sec * seconds; |
---|
| 39 | start->tv_sec += seconds; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | if (end->tv_nsec - start->tv_nsec > nsecs_per_sec) { |
---|
| 43 | int seconds = (start->tv_nsec - end->tv_nsec) / nsecs_per_sec; |
---|
| 44 | start->tv_nsec += nsecs_per_sec * seconds; |
---|
| 45 | start->tv_sec -= seconds; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | result->tv_sec = end->tv_sec - start->tv_sec; |
---|
| 49 | result->tv_nsec = end->tv_nsec - start->tv_nsec; |
---|
| 50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.