File: debug_dump.h

package info (click to toggle)
libm4ri 20240729-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,180 kB
  • sloc: ansic: 12,211; makefile: 140; sh: 72
file content (75 lines) | stat: -rw-r--r-- 3,029 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * To enable dumping of output per function, configure the library with --enable-debug-dump.
 */

/******************************************************************************
 *
 *                 M4RI: Linear Algebra over GF(2)
 *
 *    Copyright (C) 2011 Carlo Wood <carlo@alinoe.com>
 *
 *  Distributed under the terms of the GNU General Public License (GPL)
 *  version 2 or higher.
 *
 *    This code is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    General Public License for more details.
 *
 *  The full text of the GPL is available at:
 *
 *                  http://www.gnu.org/licenses/
 ******************************************************************************/

#ifndef M4RI_DEBUG_DUMP
#define M4RI_DEBUG_DUMP

#include <m4ri/misc.h>

static inline word calculate_hash(word const *rowptr, wi_t wide) {
  word hash = 0;
  for (word const *ptr = rowptr; ptr < rowptr + wide; ++ptr) { hash ^= *ptr; }
  return hash;
}

static inline word rotate_word(word w, int shift) { return (w << shift) | (w >> (m4ri_radix - w)); }

#if __M4RI_DEBUG_DUMP

struct mzd_t;
struct mzp_t;

extern void m4ri_dd_int(char const *function, char const *file, int line, int i);
extern void m4ri_dd_rci(char const *function, char const *file, int line, rci_t rci);
extern void m4ri_dd_rci_array(char const *function, char const *file, int line, rci_t *rciptr,
                              int len);
extern void m4ri_dd_rawrow(char const *function, char const *file, int line, word const *rowptr,
                           wi_t wide);
extern void m4ri_dd_row(char const *function, char const *file, int line, struct mzd_t const *M,
                        rci_t row);
extern void m4ri_dd_mzd(char const *function, char const *file, int line, struct mzd_t const *M);
extern void m4ri_dd_mzp(char const *function, char const *file, int line, struct mzp_t const *P);

#define __M4RI_DD_INT(i) m4ri_dd_int(__FUNCTION__, __FILE__, __LINE__, i)
#define __M4RI_DD_RCI(rci) m4ri_dd_rci(__FUNCTION__, __FILE__, __LINE__, rci)
#define __M4RI_DD_RCI_ARRAY(rciptr, len)                                                           \
  m4ri_dd_rci_array(__FUNCTION__, __FILE__, __LINE__, rciptr, len)
#define __M4RI_DD_RAWROW(rowptr, wide)                                                             \
  m4ri_dd_rawrow(__FUNCTION__, __FILE__, __LINE__, rowptr, wide)
#define __M4RI_DD_ROW(M, row) m4ri_dd_row(__FUNCTION__, __FILE__, __LINE__, M, row)
#define __M4RI_DD_MZD(M) m4ri_dd_mzd(__FUNCTION__, __FILE__, __LINE__, M)
#define __M4RI_DD_MZP(P) m4ri_dd_mzp(__FUNCTION__, __FILE__, __LINE__, P)

#else  // __M4RI_DEBUG_DUMP

#define __M4RI_DD_INT(i)
#define __M4RI_DD_RCI(rci)
#define __M4RI_DD_RCI_ARRAY(rciptr, len)
#define __M4RI_DD_RAWROW(rowptr, wide)
#define __M4RI_DD_ROW(M, row)
#define __M4RI_DD_MZD(M)
#define __M4RI_DD_MZP(P)

#endif  // __M4RI_DEBUG_DUMP

#endif  // M4RI_DEBUG_DUMP