1 /* Public domain. */ 2 3 #include "taia.h" 4 5 /* XXX: breaks tai encapsulation */ 6 taia_sub(struct taia * t,const struct taia * u,const struct taia * v)7void taia_sub(struct taia *t,const struct taia *u,const struct taia *v) 8 { 9 unsigned long unano = u->nano; 10 unsigned long uatto = u->atto; 11 12 t->sec.x = u->sec.x - v->sec.x; 13 t->nano = unano - v->nano; 14 t->atto = uatto - v->atto; 15 if (t->atto > uatto) { 16 t->atto += 1000000000UL; 17 --t->nano; 18 } 19 if (t->nano > unano) { 20 t->nano += 1000000000UL; 21 --t->sec.x; 22 } 23 } 24