summaryrefslogtreecommitdiff
path: root/src/libstddjb/tain_addsec.c
blob: 524ac208d562b8c59594eb43a28101527bd89520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ISC license. */

#include <skalibs/tai.h>

int tain_addsec (tain_t *b, tain_t const *a, int c)
{
  if (c >= 0)
  {
    tai_t t ;
    if (!tai_u64(&t, c)) return 0 ;
    if (!tai_add(&b->sec, &a->sec, &t)) return 0 ;
  }
  else
  {
    tai_t t ;
    if (!tai_u64(&t, -c)) return 0 ;
    if (!tai_sub(&b->sec, &a->sec, &t)) return 0 ;
  }
  b->nano = a->nano ;
  return 1 ;
}