Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / timer / subtime.c
blob17dda39a40118b06346f9c015d097bbb861dabc0
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: SubTime - subtract two timevals from each other.
6 Lang: english
7 */
8 #include "timer_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <devices/timer.h>
14 #include <proto/timer.h>
16 AROS_LH2(void, SubTime,
18 /* SYNOPSIS */
19 AROS_LHA(struct timeval *, dest, A0),
20 AROS_LHA(struct timeval *, src, A1),
22 /* LOCATION */
23 struct Device *, TimerBase, 8, Timer)
25 /* FUNCTION
26 SubTime() will subtract the src timeval from the destination
27 timeval, ie "dest - src --> dest".
29 INPUTS
30 dest - Destination timeval
31 src - Source timeval
33 RESULT
34 The timeval dest will contain the sum (dest - src).
36 NOTES
37 This function is safe to call from interrupts.
39 EXAMPLE
41 BUGS
42 May not preserve registers.
44 SEE ALSO
45 AddTime(), CmpTime()
47 INTERNALS
49 HISTORY
50 18-02-1997 iaint Implemented.
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
56 /* Normalize the terms */
57 while(src->tv_micro > 999999)
59 src->tv_secs++;
60 src->tv_micro -= 1000000;
62 while(dest->tv_micro > 999999)
64 dest->tv_secs++;
65 dest->tv_micro -= 1000000;
68 /* Check if wrap around will happen, when subtracting src->tv_micro
69 from dest->tv_micro. If yes, then normalize, by adding 1 sec to
70 micros and subtracting 1 sec from secs. Note: this check must be
71 done here, ie. before subtracting src timeval from dest timeval! */
73 if(dest->tv_micro < src->tv_micro)
75 dest->tv_micro += 1000000;
76 dest->tv_secs--;
79 dest->tv_micro -= src->tv_micro;
80 dest->tv_secs -= src->tv_secs;
82 AROS_LIBFUNC_EXIT
84 } /* SubTime */