Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libsum/sum-att.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1996-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
22
/*
23
* att
24
*/
25
26
#define att_description \
27
"The system 5 release 4 checksum. This is the default for \bsum\b \
28
when \bgetconf UNIVERSE\b is \batt\b. This is the only true sum; \
29
all of the other methods are order dependent."
30
#define att_options 0
31
#define att_match "att|sys5|s5|default"
32
#define att_open long_open
33
#define att_init long_init
34
#define att_print long_print
35
#define att_data long_data
36
#define att_scale 512
37
38
static int
39
att_block(register Sum_t* p, const void* s, size_t n)
40
{
41
register uint32_t c = ((Integral_t*)p)->sum;
42
register unsigned char* b = (unsigned char*)s;
43
register unsigned char* e = b + n;
44
45
while (b < e)
46
c += *b++;
47
((Integral_t*)p)->sum = c;
48
return 0;
49
}
50
51
static int
52
att_done(Sum_t* p)
53
{
54
register uint32_t c = ((Integral_t*)p)->sum;
55
56
c = (c & 0xffff) + ((c >> 16) & 0xffff);
57
c = (c & 0xffff) + (c >> 16);
58
((Integral_t*)p)->sum = c & 0xffff;
59
return short_done(p);
60
}
61
62