M4RI  1.0.1
debug_dump.h
Go to the documentation of this file.
1 
10 /******************************************************************************
11 *
12 * M4RI: Linear Algebra over GF(2)
13 *
14 * Copyright (C) 2011 Carlo Wood <carlo@alinoe.com>
15 *
16 * Distributed under the terms of the GNU General Public License (GPL)
17 * version 2 or higher.
18 *
19 * This code is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * The full text of the GPL is available at:
25 *
26 * http://www.gnu.org/licenses/
27 ******************************************************************************/
28 
29 #ifndef M4RI_DEBUG_DUMP
30 #define M4RI_DEBUG_DUMP
31 
32 static inline word calculate_hash(word const* rowptr, wi_t wide) {
33  word hash = 0;
34  for (word const* ptr = rowptr; ptr < rowptr + wide; ++ptr)
35  hash ^= *ptr;
36  return hash;
37 }
38 
39 static inline word rotate_word(word w, int shift) {
40  return (w << shift) | (w >> (m4ri_radix - w));
41 }
42 
43 #if __M4RI_DEBUG_DUMP
44 
45 struct mzd_t;
46 struct mzp_t;
47 
48 extern void m4ri_dd_int(char const* function, char const* file, int line, int i);
49 extern void m4ri_dd_rci(char const* function, char const* file, int line, rci_t rci);
50 extern void m4ri_dd_rci_array(char const* function, char const* file, int line, rci_t *rciptr, int len);
51 extern void m4ri_dd_rawrow(char const* function, char const* file, int line, word const* rowptr, wi_t wide);
52 extern void m4ri_dd_row(char const* function, char const* file, int line, struct mzd_t const* M, rci_t row);
53 extern void m4ri_dd_mzd(char const* function, char const* file, int line, struct mzd_t const* M);
54 extern void m4ri_dd_mzp(char const* function, char const* file, int line, struct mzp_t const* P);
55 
56 #define __M4RI_DD_INT(i) m4ri_dd_int(__FUNCTION__, __FILE__, __LINE__, i)
57 #define __M4RI_DD_RCI(rci) m4ri_dd_rci(__FUNCTION__, __FILE__, __LINE__, rci)
58 #define __M4RI_DD_RCI_ARRAY(rciptr, len) m4ri_dd_rci_array(__FUNCTION__, __FILE__, __LINE__, rciptr, len)
59 #define __M4RI_DD_RAWROW(rowptr, wide) m4ri_dd_rawrow(__FUNCTION__, __FILE__, __LINE__, rowptr, wide)
60 #define __M4RI_DD_ROW(M, row) m4ri_dd_row(__FUNCTION__, __FILE__, __LINE__, M, row)
61 #define __M4RI_DD_MZD(M) m4ri_dd_mzd(__FUNCTION__, __FILE__, __LINE__, M)
62 #define __M4RI_DD_MZP(P) m4ri_dd_mzp(__FUNCTION__, __FILE__, __LINE__, P)
63 
64 #else // __M4RI_DEBUG_DUMP
65 
66 #define __M4RI_DD_INT(i)
67 #define __M4RI_DD_RCI(rci)
68 #define __M4RI_DD_RCI_ARRAY(rciptr, len)
69 #define __M4RI_DD_RAWROW(rowptr, wide)
70 #define __M4RI_DD_ROW(M, row)
71 #define __M4RI_DD_MZD(M)
72 #define __M4RI_DD_MZP(P)
73 
74 #endif // __M4RI_DEBUG_DUMP
75 
76 #endif // M4RI_DEBUG_DUMP