summaryrefslogtreecommitdiff
path: root/src/libstddjb/uint64_unpack.c
blob: 452d3ea515470072ce692430d557bf6eb765eeec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* ISC license. */

#include <skalibs/uint64.h>
#include <skalibs/bytestr.h>

void uint64_unpack (char const *s, uint64_t *u)
{
  uint64_t r = T8((unsigned char)s[7]) ; r <<= 8 ;
  r += T8((unsigned char)s[6]) ; r <<= 8 ;
  r += T8((unsigned char)s[5]) ; r <<= 8 ;
  r += T8((unsigned char)s[4]) ; r <<= 8 ;
  r += T8((unsigned char)s[3]) ; r <<= 8 ;
  r += T8((unsigned char)s[2]) ; r <<= 8 ;
  r += T8((unsigned char)s[1]) ; r <<= 8 ;
  r += T8((unsigned char)s[0]) ;
  *u = r ;
}