summaryrefslogtreecommitdiff
path: root/tools/make-leapsecs_table
blob: c62fdde96cfca081095eaa9a3b6ebd9d0b4836b9 (plain)
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
#!/command/execlineb -P

# Compile convert-leapsecs.c, then use this to create
# src/libstddjb/leapsecs_table.c

define PREFIX ./tools

backtick -n N
{
  pipeline
  {
    redirfd -r 0 ${PREFIX}/leapsecs.txt
    ${PREFIX}/convert-leapsecs
  }
  wc -l
}
import -u N

if
{
  s6-echo "/* ISC license. */

/* MT-unsafe */

#include <skalibs/uint64.h>
#include <skalibs/tai.h>
#include \"djbtime-internal.h\"

unsigned int const leapsecs_table_len = ${N} ;
static uint64 const leapsecs_table_[${N}] =\n{"
}

if
{
  redirfd -r 0 ${PREFIX}/leapsecs.txt
  ${PREFIX}/convert-leapsecs
}

s6-echo "} ;\nuint64 const *const leapsecs_table = leapsecs_table_ ;"