1 /*
2  Copyright (C) 2010 X. Andrade
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2, or (at your option)
7  any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 
19 */
20 
21 #include <config.h>
22 typedef long long checksum_t;
23 
24 /* This function implements a very stupid checksum function. The only
25    important thing is that it produces different results for arrays
26    with the same numbers but in different orders. For more serious
27    applications a better function must be used. */
28 
FC_FUNC_(checksum_calculate,CHECKSUM_CALCULATE)29 void FC_FUNC_(checksum_calculate, CHECKSUM_CALCULATE)(const int * algorithm, const int * narray, const unsigned int * array, checksum_t * sum){
30   int i;
31   checksum_t mult;
32   *sum = 0;
33   mult = 1;
34   for(i = 0; i < *narray; i++){
35     *sum += mult*array[i];
36     mult++;
37   }
38   *sum %= (1<<31);
39 }
40