linux/lib/bch.c
<<
>>
Prefs
   1/*
   2 * Generic binary BCH encoding/decoding library
   3 *
   4 * This program is free software; you can redistribute it and/or modify it
   5 * under the terms of the GNU General Public License version 2 as published by
   6 * the Free Software Foundation.
   7 *
   8 * This program is distributed in the hope that it will be useful, but WITHOUT
   9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  11 * more details.
  12 *
  13 * You should have received a copy of the GNU General Public License along with
  14 * this program; if not, write to the Free Software Foundation, Inc., 51
  15 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  16 *
  17 * Copyright © 2011 Parrot S.A.
  18 *
  19 * Author: Ivan Djelic <ivan.djelic@parrot.com>
  20 *
  21 * Description:
  22 *
  23 * This library provides runtime configurable encoding/decoding of binary
  24 * Bose-Chaudhuri-Hocquenghem (BCH) codes.
  25 *
  26 * Call init_bch to get a pointer to a newly allocated bch_control structure for
  27 * the given m (Galois field order), t (error correction capability) and
  28 * (optional) primitive polynomial parameters.
  29 *
  30 * Call encode_bch to compute and store ecc parity bytes to a given buffer.
  31 * Call decode_bch to detect and locate errors in received data.
  32 *
  33 * On systems supporting hw BCH features, intermediate results may be provided
  34 * to decode_bch in order to skip certain steps. See decode_bch() documentation
  35 * for details.
  36 *
  37 * Option CONFIG_BCH_CONST_PARAMS can be used to force fixed values of
  38 * parameters m and t; thus allowing extra compiler optimizations and providing
  39 * better (up to 2x) encoding performance. Using this option makes sense when
  40 * (m,t) are fixed and known in advance, e.g. when using BCH error correction
  41 * on a particular NAND flash device.
  42 *
  43 * Algorithmic details:
  44 *
  45 * Encoding is performed by processing 32 input bits in parallel, using 4
  46 * remainder lookup tables.
  47 *
  48 * The final stage of decoding involves the following internal steps:
  49 * a. Syndrome computation
  50 * b. Error locator polynomial computation using Berlekamp-Massey algorithm
  51 * c. Error locator root finding (by far the most expensive step)
  52 *
  53 * In this implementation, step c is not performed using the usual Chien search.
  54 * Instead, an alternative approach described in [1] is used. It consists in
  55 * factoring the error locator polynomial using the Berlekamp Trace algorithm
  56 * (BTA) down to a certain degree (4), after which ad hoc low-degree polynomial
  57 * solving techniques [2] are used. The resulting algorithm, called BTZ, yields
  58 * much better performance than Chien search for usual (m,t) values (typically
  59 * m >= 13, t < 32, see [1]).
  60 *
  61 * [1] B. Biswas, V. Herbert. Efficient root finding of polynomials over fields
  62 * of characteristic 2, in: Western European Workshop on Research in Cryptology
  63 * - WEWoRC 2009, Graz, Austria, LNCS, Springer, July 2009, to appear.
  64 * [2] [Zin96] V.A. Zinoviev. On the solution of equations of degree 10 over
  65 * finite fields GF(2^q). In Rapport de recherche INRIA no 2829, 1996.
  66 */
  67
  68#include <linux/kernel.h>
  69#include <linux/errno.h>
  70#include <linux/init.h>
  71#include <linux/module.h>
  72#include <linux/slab.h>
  73#include <linux/bitops.h>
  74#include <asm/byteorder.h>
  75#include <linux/bch.h>
  76
  77#if defined(CONFIG_BCH_CONST_PARAMS)
  78#define GF_M(_p)               (CONFIG_BCH_CONST_M)
  79#define GF_T(_p)               (CONFIG_BCH_CONST_T)
  80#define GF_N(_p)               ((1 << (CONFIG_BCH_CONST_M))-1)
  81#else
  82#define GF_M(_p)               ((_p)->m)
  83#define GF_T(_p)               ((_p)->t)
  84#define GF_N(_p)               ((_p)->n)
  85#endif
  86
  87#define BCH_ECC_WORDS(_p)      DIV_ROUND_UP(GF_M(_p)*GF_T(_p), 32)
  88#define BCH_ECC_BYTES(_p)      DIV_ROUND_UP(GF_M(_p)*GF_T(_p), 8)
  89
  90#ifndef dbg
  91#define dbg(_fmt, args...)     do {} while (0)
  92#endif
  93
  94/*
  95 * represent a polynomial over GF(2^m)
  96 */
  97struct gf_poly {
  98        unsigned int deg;    /* polynomial degree */
  99        unsigned int c[0];   /* polynomial terms */
 100};
 101
 102/* given its degree, compute a polynomial size in bytes */
 103#define GF_POLY_SZ(_d) (sizeof(struct gf_poly)+((_d)+1)*sizeof(unsigned int))
 104
 105/* polynomial of degree 1 */
 106struct gf_poly_deg1 {
 107        struct gf_poly poly;
 108        unsigned int   c[2];
 109};
 110
 111/*
 112 * same as encode_bch(), but process input data one byte at a time
 113 */
 114static void encode_bch_unaligned(struct bch_control *bch,
 115                                 const unsigned char *data, unsigned int len,
 116                                 uint32_t *ecc)
 117{
 118        int i;
 119        const uint32_t *p;
 120        const int l = BCH_ECC_WORDS(bch)-1;
 121
 122        while (len--) {
 123                p = bch->mod8_tab + (l+1)*(((ecc[0] >> 24)^(*data++)) & 0xff);
 124
 125                for (i = 0; i < l; i++)
 126                        ecc[i] = ((ecc[i] << 8)|(ecc[i+1] >> 24))^(*p++);
 127
 128                ecc[l] = (ecc[l] << 8)^(*p);
 129        }
 130}
 131
 132/*
 133 * convert ecc bytes to aligned, zero-padded 32-bit ecc words
 134 */
 135static void load_ecc8(struct bch_control *bch, uint32_t *dst,
 136                      const uint8_t *src)
 137{
 138        uint8_t pad[4] = {0, 0, 0, 0};
 139        unsigned int i, nwords = BCH_ECC_WORDS(bch)-1;
 140
 141        for (i = 0; i < nwords; i++, src += 4)
 142                dst[i] = (src[0] << 24)|(src[1] << 16)|(src[2] << 8)|src[3];
 143
 144        memcpy(pad, src, BCH_ECC_BYTES(bch)-4*nwords);
 145        dst[nwords] = (pad[0] << 24)|(pad[1] << 16)|(pad[2] << 8)|pad[3];
 146}
 147
 148/*
 149 * convert 32-bit ecc words to ecc bytes
 150 */
 151static void store_ecc8(struct bch_control *bch, uint8_t *dst,
 152                       const uint32_t *src)
 153{
 154        uint8_t pad[4];
 155        unsigned int i, nwords = BCH_ECC_WORDS(bch)-1;
 156
 157        for (i = 0; i < nwords; i++) {
 158                *dst++ = (src[i] >> 24);
 159                *dst++ = (src[i] >> 16) & 0xff;
 160                *dst++ = (src[i] >>  8) & 0xff;
 161                *dst++ = (src[i] >>  0) & 0xff;
 162        }
 163        pad[0] = (src[nwords] >> 24);
 164        pad[1] = (src[nwords] >> 16) & 0xff;
 165        pad[2] = (src[nwords] >>  8) & 0xff;
 166        pad[3] = (src[nwords] >>  0) & 0xff;
 167        memcpy(dst, pad, BCH_ECC_BYTES(bch)-4*nwords);
 168}
 169
 170/**
 171 * encode_bch - calculate BCH ecc parity of data
 172 * @bch:   BCH control structure
 173 * @data:  data to encode
 174 * @len:   data length in bytes
 175 * @ecc:   ecc parity data, must be initialized by caller
 176 *
 177 * The @ecc parity array is used both as input and output parameter, in order to
 178 * allow incremental computations. It should be of the size indicated by member
 179 * @ecc_bytes of @bch, and should be initialized to 0 before the first call.
 180 *
 181 * The exact number of computed ecc parity bits is given by member @ecc_bits of
 182 * @bch; it may be less than m*t for large values of t.
 183 */
 184void encode_bch(struct bch_control *bch, const uint8_t *data,
 185                unsigned int len, uint8_t *ecc)
 186{
 187        const unsigned int l = BCH_ECC_WORDS(bch)-1;
 188        unsigned int i, mlen;
 189        unsigned long m;
 190        uint32_t w, r[l+1];
 191        const uint32_t * const tab0 = bch->mod8_tab;
 192        const uint32_t * const tab1 = tab0 + 256*(l+1);
 193        const uint32_t * const tab2 = tab1 + 256*(l+1);
 194        const uint32_t * const tab3 = tab2 + 256*(l+1);
 195        const uint32_t *pdata, *p0, *p1, *p2, *p3;
 196
 197        if (ecc) {
 198                /* load ecc parity bytes into internal 32-bit buffer */
 199                load_ecc8(bch, bch->ecc_buf, ecc);
 200        } else {
 201                memset(bch->ecc_buf, 0, sizeof(r));
 202        }
 203
 204        /* process first unaligned data bytes */
 205        m = ((unsigned long)data) & 3;
 206        if (m) {
 207                mlen = (len < (4-m)) ? len : 4-m;
 208                encode_bch_unaligned(bch, data, mlen, bch->ecc_buf);
 209                data += mlen;
 210                len  -= mlen;
 211        }
 212
 213        /* process 32-bit aligned data words */
 214        pdata = (uint32_t *)data;
 215        mlen  = len/4;
 216        data += 4*mlen;
 217        len  -= 4*mlen;
 218        memcpy(r, bch->ecc_buf, sizeof(r));
 219
 220        /*
 221         * split each 32-bit word into 4 polynomials of weight 8 as follows:
 222         *
 223         * 31 ...24  23 ...16  15 ... 8  7 ... 0
 224         * xxxxxxxx  yyyyyyyy  zzzzzzzz  tttttttt
 225         *                               tttttttt  mod g = r0 (precomputed)
 226         *                     zzzzzzzz  00000000  mod g = r1 (precomputed)
 227         *           yyyyyyyy  00000000  00000000  mod g = r2 (precomputed)
 228         * xxxxxxxx  00000000  00000000  00000000  mod g = r3 (precomputed)
 229         * xxxxxxxx  yyyyyyyy  zzzzzzzz  tttttttt  mod g = r0^r1^r2^r3
 230         */
 231        while (mlen--) {
 232                /* input data is read in big-endian format */
 233                w = r[0]^cpu_to_be32(*pdata++);
 234                p0 = tab0 + (l+1)*((w >>  0) & 0xff);
 235                p1 = tab1 + (l+1)*((w >>  8) & 0xff);
 236                p2 = tab2 + (l+1)*((w >> 16) & 0xff);
 237                p3 = tab3 + (l+1)*((w >> 24) & 0xff);
 238
 239                for (i = 0; i < l; i++)
 240                        r[i] = r[i+1]^p0[i]^p1[i]^p2[i]^p3[i];
 241
 242                r[l] = p0[l]^p1[l]^p2[l]^p3[l];
 243        }
 244        memcpy(bch->ecc_buf, r, sizeof(r));
 245
 246        /* process last unaligned bytes */
 247        if (len)
 248                encode_bch_unaligned(bch, data, len, bch->ecc_buf);
 249
 250        /* store ecc parity bytes into original parity buffer */
 251        if (ecc)
 252                store_ecc8(bch, ecc, bch->ecc_buf);
 253}
 254EXPORT_SYMBOL_GPL(encode_bch);
 255
 256static inline int modulo(struct bch_control *bch, unsigned int v)
 257{
 258        const unsigned int n = GF_N(bch);
 259        while (v >= n) {
 260                v -= n;
 261                v = (v & n) + (v >> GF_M(bch));
 262        }
 263        return v;
 264}
 265
 266/*
 267 * shorter and faster modulo function, only works when v < 2N.
 268 */
 269static inline int mod_s(struct bch_control *bch, unsigned int v)
 270{
 271        const unsigned int n = GF_N(bch);
 272        return (v < n) ? v : v-n;
 273}
 274
 275static inline int deg(unsigned int poly)
 276{
 277        /* polynomial degree is the most-significant bit index */
 278        return fls(poly)-1;
 279}
 280
 281static inline int parity(unsigned int x)
 282{
 283        /*
 284         * public domain code snippet, lifted from
 285         * http://www-graphics.stanford.edu/~seander/bithacks.html
 286         */
 287        x ^= x >> 1;
 288        x ^= x >> 2;
 289        x = (x & 0x11111111U) * 0x11111111U;
 290        return (x >> 28) & 1;
 291}
 292
 293/* Galois field basic operations: multiply, divide, inverse, etc. */
 294
 295static inline unsigned int gf_mul(struct bch_control *bch, unsigned int a,
 296                                  unsigned int b)
 297{
 298        return (a && b) ? bch->a_pow_tab[mod_s(bch, bch->a_log_tab[a]+
 299                                               bch->a_log_tab[b])] : 0;
 300}
 301
 302static inline unsigned int gf_sqr(struct bch_control *bch, unsigned int a)
 303{
 304        return a ? bch->a_pow_tab[mod_s(bch, 2*bch->a_log_tab[a])] : 0;
 305}
 306
 307static inline unsigned int gf_div(struct bch_control *bch, unsigned int a,
 308                                  unsigned int b)
 309{
 310        return a ? bch->a_pow_tab[mod_s(bch, bch->a_log_tab[a]+
 311                                        GF_N(bch)-bch->a_log_tab[b])] : 0;
 312}
 313
 314static inline unsigned int gf_inv(struct bch_control *bch, unsigned int a)
 315{
 316        return bch->a_pow_tab[GF_N(bch)-bch->a_log_tab[a]];
 317}
 318
 319static inline unsigned int a_pow(struct bch_control *bch, int i)
 320{
 321        return bch->a_pow_tab[modulo(bch, i)];
 322}
 323
 324static inline int a_log(struct bch_control *bch, unsigned int x)
 325{
 326        return bch->a_log_tab[x];
 327}
 328
 329static inline int a_ilog(struct bch_control *bch, unsigned int x)
 330{
 331        return mod_s(bch, GF_N(bch)-bch->a_log_tab[x]);
 332}
 333
 334/*
 335 * compute 2t syndromes of ecc polynomial, i.e. ecc(a^j) for j=1..2t
 336 */
 337static void compute_syndromes(struct bch_control *bch, uint32_t *ecc,
 338                              unsigned int *syn)
 339{
 340        int i, j, s;
 341        unsigned int m;
 342        uint32_t poly;
 343        const int t = GF_T(bch);
 344
 345        s = bch->ecc_bits;
 346
 347        /* make sure extra bits in last ecc word are cleared */
 348        m = ((unsigned int)s) & 31;
 349        if (m)
 350                ecc[s/32] &= ~((1u << (32-m))-1);
 351        memset(syn, 0, 2*t*sizeof(*syn));
 352
 353        /* compute v(a^j) for j=1 .. 2t-1 */
 354        do {
 355                poly = *ecc++;
 356                s -= 32;
 357                while (poly) {
 358                        i = deg(poly);
 359                        for (j = 0; j < 2*t; j += 2)
 360                                syn[j] ^= a_pow(bch, (j+1)*(i+s));
 361
 362                        poly ^= (1 << i);
 363                }
 364        } while (s > 0);
 365
 366        /* v(a^(2j)) = v(a^j)^2 */
 367        for (j = 0; j < t; j++)
 368                syn[2*j+1] = gf_sqr(bch, syn[j]);
 369}
 370
 371static void gf_poly_copy(struct gf_poly *dst, struct gf_poly *src)
 372{
 373        memcpy(dst, src, GF_POLY_SZ(src->deg));
 374}
 375
 376static int compute_error_locator_polynomial(struct bch_control *bch,
 377                                            const unsigned int *syn)
 378{
 379        const unsigned int t = GF_T(bch);
 380        const unsigned int n = GF_N(bch);
 381        unsigned int i, j, tmp, l, pd = 1, d = syn[0];
 382        struct gf_poly *elp = bch->elp;
 383        struct gf_poly *pelp = bch->poly_2t[0];
 384        struct gf_poly *elp_copy = bch->poly_2t[1];
 385        int k, pp = -1;
 386
 387        memset(pelp, 0, GF_POLY_SZ(2*t));
 388        memset(elp, 0, GF_POLY_SZ(2*t));
 389
 390        pelp->deg = 0;
 391        pelp->c[0] = 1;
 392        elp->deg = 0;
 393        elp->c[0] = 1;
 394
 395        /* use simplified binary Berlekamp-Massey algorithm */
 396        for (i = 0; (i < t) && (elp->deg <= t); i++) {
 397                if (d) {
 398                        k = 2*i-pp;
 399                        gf_poly_copy(elp_copy, elp);
 400                        /* e[i+1](X) = e[i](X)+di*dp^-1*X^2(i-p)*e[p](X) */
 401                        tmp = a_log(bch, d)+n-a_log(bch, pd);
 402                        for (j = 0; j <= pelp->deg; j++) {
 403                                if (pelp->c[j]) {
 404                                        l = a_log(bch, pelp->c[j]);
 405                                        elp->c[j+k] ^= a_pow(bch, tmp+l);
 406                                }
 407                        }
 408                        /* compute l[i+1] = max(l[i]->c[l[p]+2*(i-p]) */
 409                        tmp = pelp->deg+k;
 410                        if (tmp > elp->deg) {
 411                                elp->deg = tmp;
 412                                gf_poly_copy(pelp, elp_copy);
 413                                pd = d;
 414                                pp = 2*i;
 415                        }
 416                }
 417                /* di+1 = S(2i+3)+elp[i+1].1*S(2i+2)+...+elp[i+1].lS(2i+3-l) */
 418                if (i < t-1) {
 419                        d = syn[2*i+2];
 420                        for (j = 1; j <= elp->deg; j++)
 421                                d ^= gf_mul(bch, elp->c[j], syn[2*i+2-j]);
 422                }
 423        }
 424        dbg("elp=%s\n", gf_poly_str(elp));
 425        return (elp->deg > t) ? -1 : (int)elp->deg;
 426}
 427
 428/*
 429 * solve a m x m linear system in GF(2) with an expected number of solutions,
 430 * and return the number of found solutions
 431 */
 432static int solve_linear_system(struct bch_control *bch, unsigned int *rows,
 433                               unsigned int *sol, int nsol)
 434{
 435        const int m = GF_M(bch);
 436        unsigned int tmp, mask;
 437        int rem, c, r, p, k, param[m];
 438
 439        k = 0;
 440        mask = 1 << m;
 441
 442        /* Gaussian elimination */
 443        for (c = 0; c < m; c++) {
 444                rem = 0;
 445                p = c-k;
 446                /* find suitable row for elimination */
 447                for (r = p; r < m; r++) {
 448                        if (rows[r] & mask) {
 449                                if (r != p) {
 450                                        tmp = rows[r];
 451                                        rows[r] = rows[p];
 452                                        rows[p] = tmp;
 453                                }
 454                                rem = r+1;
 455                                break;
 456                        }
 457                }
 458                if (rem) {
 459                        /* perform elimination on remaining rows */
 460                        tmp = rows[p];
 461                        for (r = rem; r < m; r++) {
 462                                if (rows[r] & mask)
 463                                        rows[r] ^= tmp;
 464                        }
 465                } else {
 466                        /* elimination not needed, store defective row index */
 467                        param[
 4)
 445p = -><4 href="+code=deg" class=4sref"47>tmp;
 461          "sref">rem;              ="sref">r =  443<="sref">r = r+1;
 e=elp" class="sref">"sref">rem; p = ef="+code=i" class="line" name="L463"> 463                                        rc#L375" i4="L375" class="line" nam4="L3747">l);
bch,
 444          gned int 4m];
-1) {
 451                                        i 4                  class="line" name="L467"> 467           a="L445" class="line"-1])) ?a>];
p) {
           a="L445" class="line"--,  class="sref"" class="sref">"sref">rem; i) :#L419" id="L419"me="L451"> 451                                        tmp = p];
 = 4yn[0];
   /a>                        class="sref">p = ee=r" class="sref">ra href="+4ode=poly_2t" class="sref4>poly48 = 0;
 *            , p48">l);
 444          c#L386" i4="L386" class="line" nam4="L3848 426}
t));
 443 443 443        for (p = c < (4ref="+code=deg" class="s4ef">d49*/
 467           s="sref">c < <]f="+               <                467           s="sref">c < <]f=de=i" ~1)|4" id="L461" clasa="L445" class="line" =li/ href="+code=c" class="sref">c < < class="/a>/32] &= ~((1u <4a>->c<49yn));
d49mask)
c<49++) {
 4L444"> 444          c#L394" i4="L394" class="line" nam4="L3949 = 0;
 461          "sref">rem;              ="sref">r =  443<="sref">r = tmp = i/32] &= ~((1u <4a#L386" i4++) {
|                  clitass="line" name="clita460""" class="sref">"ef">rows["sref">rem; i)>/32] &= ~((1u <4aY_SZ4 (d) {
i-pp;
i 433                                           rows[
{
x]);
}
c 333
c[sL4" class="line" L461lass      ots="lia degreeL334" id="L334" class="line"5s6ef">cary Berlekamp-Massey al5s="sr502t
ca href="+code=i" class=5     5      pan>
 407        5     5      pan>
inline int a_ilog(struct bch_control
bch_control)-bch_control        int deg5/a>+k;
bch_control *otsed int * =5tmp;
 381        unsigned int p = elp5copy);
 435        const int m = pd = d;
rows[c}
 415        5     5         }
 381        unsigned int <                                     l = c 4165     51> 386
l = t));
param[t));
i+2];
degj++)
rem; deg <= i52-j]);
deg <= l = t)href=_ta/a>)-j],  4225     52mask)
l = t)href=_ta/a>)-l = p = e] : 0)^="+code=t" class="sre5eef">pd5423tmp;
l = t)href=_ta/a>)-l = (<5 href="+code=elp" class=5sref"52 = 0;
elp->c 386
]);
 <5"> 428
deg
j]);
 428                        for (                        for ( 436        unsigned int  436        unsigned int rows,
 436                  elp->pdtmp;
rows[c[c["b/bch.c#L445" ief">elp->rows[r+1;
c[ 436     ssref">rows[c["b/bch.c#L445" ief">elp->rows[cparam<5a>[ 438
 432static int ode=l" class="sref">l =  b/bch.c#L457" id="L4575 = 1 <5lt; m;
 441b408" id="L408" class="l431" id="L431" class="line" 5n class="5omment">/* Gaussian elim5natio5 */
pd 333
r5m pan>
inline int a_ilog(struct  383        L383" class="line"me="L383e="L431" class="line" 5="sref">c5/a>-k;
bch_control *otsed int */* f5nd suitable row for elim5natio5 */m;5++) {
 L444"> 444         5& 54>t));
r 5= p) {
 393        rows<5a>[r];
 4c!=0,e  ot=c/bc*L431" id="L431" class="line" 5ef">rows<5a>[p];
l = n = il = t)hrlog_ta/a>)- 393        tmp;
ref">l = t)hrlog_ta/a>)- 393                        5     5         }
r 4555/a>                     5     55/a> = -1;
 456        5     55     pan>
 4575     55> 427

/* perfo5m elimination on remaini5g row5 */
inline int a_ilog(struct  383        L383" class="line"me="L383e="L431" class="line" 5ef">rows<5a>[p];
bch_control *otsed int *m;5+f="+code=t" class="sre5] & <5 href="+code=mask" class5"sref5>mask)
 Lde=a_log" class="81" class="line" name="L381"> 381 l01" class="line"l0name="L381"> 381 l11" class="line"l1name="L381"> 381 l21" class="line"l2L380ref="+code=i" class="s5r] ^=5d;
 381 v1" class="line"vlass=e=a_log" class=" ed int * 464        5     56 374}
 465       5     5  } else {
 393         393         381 l01" class="line"l0name+code=syn" class="ref">l = t)hrlog_ta/a>)- 393        l = t)hrlog_ta/a>)- 393        k;
 381 l21" class="line"l2L380+code=syn" class="ref">l = t)hrlog_ta/a>)- 393        rows<5="L370" class="line" nam5="L3757f">m;
p];
/* di+1 = S(2i+3)+5#L372" id5"L372" class="line" name5"L37257mask)
j+k] ^= n = igf_poly5/a>-><5 href="+code=deg" class=5sref"57>tmp;


/* di+1 = S(2i+3)+5GF_T(5a href="+code=bch" class5"sref58>p) {
 L444"> 444         5GF_N(5a href="+code=bch" class5"sref58">p];
 381 v1" class="line"vlasss="               u1" class="line"uname444"> 444         5Goly 5href="+code=syn" class="5ref">58">p];
                ? -1 : (int) 444         5Ga>-><5ode=poly_2t" class="sref5>poly58>tmp;
l = t)xi_ta/a>)-j],  444         5Gine" nam5ode=poly_2t" class="sref5>poly58 = 0;
 381 v1" class="line"vlasss^  /a>                        "sref">j],  444         5Gline" na5href="+code=pp" class="s5ef">p58">l);
/* di+1 = S(2i+3)+5Gned int 52*&quosqc"+code=k" class="sref">k] ^= )^              < ="line" name="L461">) 4                 u1" class="line"unameeef="+code=t" class="sre5/* di+1 = S(2i+3)+5c#L389" i5="L389" class="line" nam5="L3859>p) {
k] ^= n = i/* di+1 = S(2i+3)+5cF_N(5ref="+code=deg" class="s5ef">d59*/
l = t)hrlog_ta/a>)-tmp =  444         5a>->c<59++) {
k] ^= n = i/* di+1 = S(2i+3)+5cL372" id5ref="+code=deg" class="s5ef">d59mask)
l = t)hrlog_ta/a>)-tmp =  444         5aa>-><5href="+code=c" class="sr5f">c<59++) {
+b/bch.c#L457" id="L4575cned int 5 (m];
i-, 6a href="+code=elp" class6"sref60s,


inline int a_ilog(struct  383        L383" class="line"me="L383e="L431" class="line" 6>deg;6)
bch_control *otsed int *c)
c[ 381 ass="line" name="L380"> L444"> 444         6s6ef">cary Berlekamp-Massey al6s="sr60bch);
bch_control)- 393        bch_controlbch_controlbch_controlbch_controlrows[ 444         6s7ef">ca href="+code=i" class=6     60 426}
 407        6     60++) {
 393        
deg6/a>+k;
 447   L383" class="line"me="L383ine" name="L393"> 393         444         6/a>-><6 href="+code=deg" class=6sref"61">p];
 381 c21" class="line"c2ntro="L447"> 447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^=  393        bch_control 444         6deg =6p];
 447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^=  393        bch_control 444         6ddeg;6ode=elp_copy" class="sre6">elp61mask)
 447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^=  393        bch_control 444         6def">c = d<44"> 444         6dref">c = 0;
/* di+1 = S(2i+3)+6line" nam6="L415"> 415        6     61cc++;
 447   namuf="+code=a_ilog" namuf"+code=k" class="sref">k] ^= bch_control/* di+1 = S(2i+3)+6l7ef">c 4166     61        }
 447   namuf="+code=a_ilog" namuf"+code=k" class="sref">k] ^= bch_control 381 ahref="+code=bchantro e"447"> 447   nasqclass="string">&quosqc"+code=k" class="sref">k] ^= t));
k;
degp];
k] ^= bch_control)- 393        rows[i62-j]);
/bch.c#L446" id="L446" cremove a2 fromclas35 list="li  ots=#L431" id="L431" class="line" 6fdeg;6ne" name="L422"> 4226     62mask)
deg <= pd6423tmp;
rows[deg <= c = 0;
l = rows[deg <=  444         6sine" nam6c+2];
 428degm;
 431 441b408" id="L408" class="l431" id="L431" class="line" 6ed int *<6 href="+code=rows" class6"sref63*/
pd 333
 pan>
inline int a_ilog(struct  383        L383" class="line"me="L383e="L431" class="line" 6#ine" nam6a href="+code=bch" class6"sref63 } else {
bch_control *otsed int *cparam<6a>[ 381 f="+code=a_ilog"lname="L381"> 381 ass="line" name="L380"> L444"> 444         6f/a> <6="L438" class="line" nam6="L436"> 438
bch_control)- 393        bch_control Ll">bch_controlbch_controlbch_controlbch_control ef="+code=i" class="s6a">degp];
 393         444         6n class="6omment">/* Gaussian elim6natio64 332}
pdtmp;
r64 = 0;
bch_control 447   L383" class="line"me="L383ine" name="L393"> 393         444         6="sref">c6/a>- 381 d         447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^=  393        bch_control 444         6ent">/* f6nd suitable row for elim6natio64> 386
 447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^=  393        bch_control 444         6e">param<6++) {
)- 447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^=  393        bch_control 444         6e/a> <6ref="+code=mask" class="6ref">649/a>++) {
 447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^=  393        bch_control 444         6f">r 6= rows<6a>[r];
rows<6a>[p];
tmp;
 4ae^2+c=0c#L431" id="L431" class="line" 6me="L453"6 453                6     65>tmp;
c < < cf="+code=t" class="sre6e     c6/a>                     6     65 } else {
 447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^=  444         6fnt">/* f6="L456"> 456        6     65++) {
l =  444         6f">param<6ne" name="L457"> 4576     65f="+code1 name2+code=href="lib/bch.c#L444" if="+code=a_ilog"lnames+2 436     f="+code=a_ilog"lnameslass="/a ?ode=syn" class="const unsigned int n =  444         6f/a> <6 href="+code=rem" class=6sref"65f="+code=GF_T" 20358"href="libbch_control                  s="sref">j+k] ^=  444         6>/* perfo6m elimination on remaini6g row66>p) {
rows<6a>[m;6 441b408" id="L408" class=cccccccccccccccccccccccccd=z^4+e^4 + a(z^3+ez^2+e^2z+e^3) + b(z^2+e^2) +cz+ce+d431" id="L431" class="line" 6f class="6 href="+code=mask" class6"sref66*/
 464        6     66/*
c6e="L465"> 465       6     662t
++) {
         447    s="sref">j+k] ^= k] ^=  39fed int *         444         6>">param<6ws" *5id="L355" 2="liba56 )- 447   namuf="+code=a_ilog" namuf"+code=k" class="sref">k] ^= bch_control)- 444         6>/a> <6code=         Xu1href=> 6 k;
rows<6="L370" class="line" nam6="L3767">p];
p];
)
 444         6/a>-><6 href="+code=deg" class=6sref"67f">d<44"> 444         6#ine" nam6"L374" class="line" name6"L37467 = 0;
 447   nainv1" class="line" nainv"+code=k" class="sref">k] ^=  444         6#line" na6="L375" class="line" nam6="L3767cc++;
 447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^= bch_control         444         6#on not n6 447   nadiv1" class="line" nadiv"+code=k" class="sref">k] ^=  39d         444         6#">param<6
(6a href="+code=bch" class6"sref68>p) {
 447  d         444         6GF_N(6a href="+code=bch" class6"sref68">p];
 381 /21" class="line"b2ntro="L447"> 447  sref">param[68">p];
 447  /a>)- 444         6k] ^= bch_controlbch_controlbch_controlp68">l);
deg <= /* di+1 = S(2i+3)+6Gned int 62* 447  ahref="+code=bchantro ?ode=syn" class=" nainv1" class="line" nainv"+code=k" class="sref">k] ^= deg <= deg <=  444         6deg <= l =  444         6c#L389" i6="L389" class="line" nam6="L3869>p) {
d69*/
 4444"> 444         6coly 6href="+code=c" class="sr6f">c<69++) {
d69mask)
c<69+b/bch.c#L457" id="L4576cine" nam6="L394" class="line" nam6="L3969 374}


/* di+1 = S(2i+3)+6sref">i-inline int a_ilog(struct /* di+1 = S(2i+3)+7opy, 7a href="+code=elp" class7"sref70>p) {
 383       ahref="+code=bchantrol"ref">bch_control rp1" class="line"hrpf="+h p];
 381 d         447   href="+code=bchantroine" name="L393"> 39 ? -1 : (int) 447  const unsigned int n = il =  393         447   href="+code=bchantroine" name="L393"> 39 ? -1 : (int) 444         7>deg;7}
ctmp;
 4-0c[ 447  d        deg <= cary Berlekamp-Massey al7s="sr70cc++;
deg <=  393         447  ref">deg <= l = l =  393         447  ref">deg <= ca href="+code=i" class=7     70+b/bch.c#L457" id="L4577line" nam7="L407"> 407        7     70">m];

deg7/a>+
 =7inline int a_ilog(struct  383       ahref="+code=bchantrol="L431" class="line" 7ddeg;7ode=elp_copy" class="sre7">elp71mask)
 383       /a>)-bch_control rp1" class="line"hrpf="+h c = c = 0;
bch_controlbch_control 415        7     71bch);
 381 j1" class="line"jname=">bch_control" id="L443" class="line"447"> 447   href="+code=bchantroine" name="L393"> 393        c 4167     71        }
 447  /a>)- 39 ? -1 : (int)m];
 39 ? -1 : (int) 447  d        k;
degm;
i72-j]);
;7ne" name="L422"> 4227     72mask)
 rp1" class="line"hrpf="+hef="+code=t" class="sre7eef">pd7423tmp;
l = t)cache1" class="line"cache"+coref="+code=i" class="s7eref">c = 0;
l =  39 rp1" class="line"hrpf="+href="+code=i" class="s7eine" nam7c}
 447   href="+code=bchantroine" name="L393"> 39 ? -1 : (int) 447  j1" class="line"jname=ne" "L447"> 447  d         447  j1" class="line"jname--hef="+code=t" class="sre7e9ne" nam7"> 428c < <"447"> 447  j1" class="line"jnamechef="+code=t" class="sre7 GF(2) wi7h an expected number of 7oluti73>p) {
l = c < <"447"> 447  j1" class="line"jnamechref="+code=i" class="s7 ">deg
 447  d        i7> 431p];
 447  d        deg <= bch_control)
deg <= pdtmp;
 = 0;
c < <"447"> 447  p1" class="line"pntro]""+code=rows" classref">l = t)href=_ta/a>)- 447  "od_            l = ]);
a_pow" class="m           cparam<7a>[ 438
p) {
 39 ? -1 : (int) 447  d        degp];
3         447   href="+code=bchantroine" name="L393"> 39 ? -1 : (int) 447   href="+code=bchantroine" name="L393"> 39 ? -1 : (int) 447   href="+code=bchantroine" name="L393"> 39 ? -1 : (int)/* Gaussian elim7natio74 332pdd<44"> 444         7      r74/*
c7/a>-/* f7nd suitable row for elim7natio74     pan>
param<7+pan>
inline int a_ilog(struct  383       ahref="+code=bchantrol="L431" class="line" 7e/a> <7ref="+code=mask" class="7ref">74f="+code=GF_T" 20358"href="liss=st"href="lib/bch.c#L383" id="L383" class="line" name="L383"> 383       /a>)- 383       q3" class="line"q"+coh r 7= rows<7a>[r];
 39 ? -1 : (int) 447  /a>)- 39 ? -1 : (int)rows<7a>[ 447  q3" class="line"q"+coine" name="L393"> 39 ? -1 : (int) 447   href="+code=bchantroine" name="L393"> 39 ? -1 : (int) 447  /a>)- 39 ? -1 : (int)tmp;
/* di+1 = S(2i+3)+7me="L453"7 453                7     75>tmp;
l = bch_control)- 39NULLa>)-/bch.c#L446" id="L446" cquoti/bc =s"hrorlib/b upper part="liname="L335 ac#L431" id="L431" class="line" 7m"sref">c7/a>                     7     75 } else {
 393         447   href="+code=bchantroine" name="L393"> 393         447  /a>)- 39 ? -1 : (int) 39 ? -1 : (int)/* f7="L456"> 456        7     75++) {
param<7ne" name="L457"> 4577     75f="+code1 name2+code=447"> 447  q3" class="line"q"+coine" name="L393"> 39 ? -1 : (int) 444         7f/a> <7 href="+code=rem" class=7sref"75f="+code=GF_T" 20358"ode=l" class="sq3" class="line"q"+coine" name="L393"> 393         444         7>/* perfo7m elimination on remaini7g row76>p) {
rows<7a>[rows<7 441/bch.c#L457" id="L4577e class="7 href="+code=mask" class7"sref76*/
 464        7     76/*
c7e="L465"> 465       7     762t
 383        na"L38 gcd1" class="line" na"L38 gcdf="+cass="sref">inline int a_ilog(struct  383       ahref="+code=bchantrol="L431" class="line" 7ion not n7eded, store defective ro7 inde76++) {
 383       /a>)-">param<7ws" *5id="L355" 2="liba57  383       s="sref">rows[ 444         7#L369" id7"L369" class="line" name7"L36977 ef="+code=i" class="s7#f">rows<7="L370" class="line" nam7="L3777">p];
 39 b -1 : (int)"gcd(%s,%s)="431" idl"name="L393"> 39 na"L38 hre1" class="line" na"L38 href="+code=l" class="sahref="+code=bchantrocl"name="L393"> 39 na"L38 hre1" class="line" na"L38 href="+code=l" class="s/a>)-)
 39 ? -1 : (int) 447  /a>)- 39 ? -1 : (int)tmp;
rows[ 447  /a>)- 444         7#ine" nam7"L374" class="line" name7"L37477 = 0;
)- 447  ahref="+code=bchantro444"> 444         7#"sref">c7="L375" class="line" nam7="L3777cc++;
 447  s="sref">rows[ 444         7#on not n7param<7m];

 447  /a>)- 39 ? -1 : (int)p) {
l = bch_control)- 39NULLa>)-p];
 381 s="sref">rows[ 447  /a>)- 444         7Goly 7href="+code=syn" class="7ref">78">p];
 447  ahref="+code=bchantro444"> 444         7/bch.c#L356" iahref="+code=bchantro e"447"> 447  s="sref">rows[ 444         7Ga>-><7ode=poly_2t" class="sref7>poly78>tmp;
p78        }
 381 db -1 : (int)"%s\n"431" idl"name="L393"> 39 na"L38 hre1" class="line" na"L38 href="+code=l" class="sahref="+code=bchantrochref="+code=i" class="s7Gon not n7="L386" class="line" nam7="L3878 426}
 444         7d79ns
 7href="+code=c" class="sr7f">c<79> 441b408" id="L408" class=c* Givenia name="L335 f and f="integer k,Lne" nameTr(a^kX) "od f431" id="L431" class="line" 7cL372" id7ref="+code=deg" class="s7ef">d79*/
-><7href="+code=c" class="sr7f">c<79> 333
inline int a_ilog(struct  383       fed int * 383       z3" class="line"zntrol="L431" class="line" 7con not n7++) {
 383       out3" class="line"outntroh i-l = p) {
 381 j1" class="line"jnameref="+code=i" class="s8o1y, 8aef="+code=deg" class="s8[p](X80f">m;
j]);
deg;8tmp;
       z3" class="line"zntroine" name="L393"> 39 ? -1 : (int)ctmp;
       z3" class="line"zntroine" name="L393"> 393         444         8sref">c[ 393        l = t)href=_ta/a>)- 447  khref="+code=bchkntro]4ef="+code=i" class="s8s6ef">cary Berlekamp-Massey al8s="sr80ccca href="+code=i" class=8     80> 386
 39 ? -1 : (int) 444         8line" nam8="L407"> 407        8     80++) {
bch_control 39 ? -1 : (int)deg8/a>+p];
 39id="L38 hrehrp1" class="line" na"L38 hrehrpf="+code=l" class="sref">l = l = t)cache1" class="line"cache"+cohref="+code=i" class="s8deg =8elp81mask)
 447  m           deg <= c = c = 0;
 447  z3" class="line"zntroine" name="L393"> 39 ? -1 : (int) 447  j1" class="line"jname=ne" "L na"lib/bch.c#L396j1" class="line"jname--hef="+code=t" class="sre8line" nam8="L415"> 415        8     81 } else {
 39s="sref">c < <"447"> 447  j1" class="line"jnamec""+code=rows" classz3" class="line"zntroine" name="L393"> 393         447  j1" class="line"jnamecref="+code=i" class="s8d7ef">c 4168     81++) {
 393         447   nasqe1" class="line" nasqef="+code=l" class="sref">l =  393         447  j1" class="line"jnamechref="+code=i" class="s8dine" nam8S(2i+2)+...+elp[i+1].lS(8i+3-l81f="+code1 name2+code=href="libbch_control 393         444         8s9ne" nam8k;
 39 ? -1 : (int) 39 ? -1 : (int)degbch_control 39 ? -1 : (int) 447  z3" class="line"zntroine" name="L393"> 39 ? -1 : (int) =82- 4228     82>tmp;
 447  m           pd8423tmp;
 39 ? -1 : (int)c = 0;
l = l = t)cache1" class="line"cache"+cohref="+code=i" class="s8s7ef">c++) {
 428 39s="sref">c < <"447"> 447  out3" class="line"outntroine" name="L393"> 39 ? -1 : (int) 447  out3" class="line"outntroine" name="L393"> 39 ? -1 : (int)p) {
 447  out3" class="line"outntroine" name="L393"> 39 ? -1 : (int)degm;
i8> 431p];
 39 b -1 : (int)"Tr(a^%d.X) "od fn"L%s\n"431" idl"name="L393"> 39khref="+code=bchkntrol"name="L393"> 39 na"L38 hre1" class="line" na"L38 href="+code=l" class="sout3" class="line"outntrohhref="+code=i" class="s8ed int *<8 href="+code=rows" class8"sref83 332pdd<44"> 444         8#L434" id8"L434" class="line" name8"L43483/*

c
param<8a>[inline int a_ilog(struct  383       fed int *> 383        3" class="line" ntrol"href="lib/bch.c#L383" id="L383" class="line" name="L383">> 383        href="+code=bchh"+coh  f="+code=t" class="sre8a">degp];
 383       f21" class="line"f2ntro="L447"> 447  /ef">l = t)"L38 2t3" class="line""L38 2tref="+cref="+code=i" class="s8c#L441" i8="L441" class="line" nam8="L4484>j]);
 383       q3" class="line"q"+co ="L447"> 447  /ef">l = t)"L38 2t3" class="line""L38 2tref="1cref="+code=i" class="s8cd int *<8omment">/* Gaussian elim8natio843j]);
 383       tkhref="+code=bchtkntro="L447"> 447  /ef">l = t)"L38 2t3" class="line""L38 2tref="2cref="+code=i" class="s8cef">pd]);
 383       z3" class="line"zntro ="L447"> 447  /ef">l = t)"L38 2t3" class="line""L38 2tref="3cref="+code=i" class="s8cL434" id8ref="+code=rem" class="s8ef">r845j]);
 383       gcd1" class="line" cdntro4ef="+code=i" class="s8="sref">c8/a>-/* f8nd suitable row for elim8natio84> 386

"lactre    %s...\n"431" idl"name="L393"> 39 na"L38 hre1" class="line" na"L38 href="+code=l" class="sfed int *param<8m];
84f="+code=GF_T> 383        3" class="line" ntro="L447"> 447  fed int *r 8=  383        href="+code=bchh"+co="L447"> 447  NULLa>)-deg[m;
rows<8a>[l =  39fed int *                8     85f">d<44"> 444         8e      39 ? -1 : (int)c8/a>                     8     85 } else {
/* di+1 = S(2i+3)+8ent">/* f8="L456"> 456        8     85++) {
 39 na"L38 cop83" class="line" na"L38 cop8f="+code=l" class="sf21" class="line"f2ntrol"name="L393"> 39fed int *param<8ne" name="L457"> 4578     85f="+code1 name2+code=447"> 447  gcd1" class="line" cdntro""L447"> 447   na"L38 gcd1" class="line" na"L38 gcdf="+code=l" class="sref">l =  39tkhref="+code=bchtkntrohref="+code=i" class="s8m/a> <8 href="+code=rem" class=8sref"85f="+code=GF_T" 20358"#"L403" class="linegcd1" class="line" cdntroine" name="L393"> 39 ? -1 : (int) 447  fed int * 39 ? -1 : (int)/* di+1 = S(2i+3)+8ef">rows<8a>[bch_controll = rows<8p];
/* di+1 = S(2i+3)+8e class="8 href="+code=mask" class8"sref86mask)
inline  na"L38 deg11" class="line" na"L38 deg1L383">)name="L393"> 39fed int * 447  gcd1" class="line" cdntroine" name="L393"> 39 ? -1 : (int)t)"L383" class="line""L38f="+ref="+code=i" class="s8fe="L453"8 447  gcd1" class="line" cdntrohref="+code=i" class="s8e      464        8     86 = 0;
c8e="L465"> 465       8     86 } else {
param<8ws" *5id="L355" 2="liba58 
rows<8="L370" class="line" nam8="L3787ns
rows<8
/* di+1 = S(2i+3)+8/a>-><8 href="+code=deg" class=8sref"87>tmp
inline int a_ilog(struct  = 0;
 383       "L383" class="line""L38f="+l"href="lib/bch> 383       rootsed int *c8="L375" class="line" nam8="L3787ccparam<8 383       f11" class="line"f1f="+l"> 383       f21" class="line"f2ntroref="+code=i" class="s8#/a> <8"L378" class="line" name8"L37887/*p) {
 39 ? -1 : (int)p];
 4ad hoc techniques #="comment">/* di+1 = S(2i+3)+8Goly 8href="+code=syn" class="8ref">88">p];
/* di+1 = S(2i+3)+8G class="8/bch.c#L356" icnt3" class="line"cntf="+="L447"> 447  finda"L38 deg1 rootsed int *l =        rootsed int */* di+1 = S(2i+3)+8G"sref">c8href="+code=pp" class="s8ef">p88cc++;
 447  finda"L38 deg2 rootsed int *l =        rootsed int *param<82*/* di+1 = S(2i+3)+8G/a> <82* 447  finda"L38 deg3 rootsed int *l =        rootsed int *d891="+code1 namcase 4:t">/* di+1 = S(2i+3)+8coly 8href="+code=c" class="sr8f">c<89">p];
 447  finda"L38 deg4 rootsed int *l =        rootsed int *d89>tmp;
c<89>tmp;
/* di+1 = S(2i+3)+8cine" nam8="L394" class="line" nam8="L3989 = 0;
/* di+1 = S(2i+3)+8cline" na8nary Berlekamp-Massey al8orith89 } else {
 444         8con not n8++) {
 39 ? -1 : (int)l = l =  39"L383" class="line""L38f="+l"lass=447"> 447  f11" class="line"f1f="+l"lass=447"> 447  f21" class="line"f2ntrohref="+code=i" class="s8c/a> <8>-, 9a href="+code=elp" class9"sref90>p) {
 447  finda"L38 rootsed int *l =        rootsed int *p];
 447  finda"L38 rootsed int *l =  39rootsed int *tmp;
ctmp;
c[cary Berlekamp-Massey al9s="sr90 } else {
ca href="+code=i" class=9     90> 386b/bch.c#L457" id="L4579r8ef">c(m];
 39 ?lined        deg9/a>+
, 9;9ode=elp_copy" class="sre9">elp91*/
/* di+1 = S(2i+3)+9def">c = inline int a_ilog(struct c = 0;
 383       "3" class="line""f="+l"href="lib/bch> 383       rootsed int * 415        9     91ccc 4169     91        }
c 381 j1" class="line"jname="L381"> 381 synhref="+code=bchsynname="L381"> 381 syn0href="+code=bchsyn0name="L381"> 381 count3" class="line"countf="+="LL444"> 444         9s9ne" nam9 383       lenhref="+code=bchlenntro+code=bch" class/ef">l = t)ecc_bitsed int * ef="+code=i" class="s9f">deg/* di+1 = S(2i+3)+9feg =92-p];
 39id="L38 hrehrp1" class="line" na"L38 hrehrpf="+code=l" class="sref">l = l = t)cache1" class="line"cache"+cohref="+code=i" class="s9fdeg;9ne" name="L422"> 4229     92>tmp;
       /ef">l = t)cache1" class="line"cache"+co"447"> 447  "3" class="line""f="+ine" name="L393"> 39 ? -1 : (int) 444         9eef">pd9423tmp;
 381 syn0href="+code=bchsyn0name""L447"> 447   nadiv1" class="line" nadivf="+code=l" class="sref">l =  393         393         447  "3" class="line""f="+ine" name="L393"> 39 ? -1 : (int)c}
l =  447  khref="+code=bchkntro+1na"lib/bch.c#L396" id="L396" class="linf="+e"               GF_N           l = deg <= c++) {
/* di+1 = S(2i+3)+9f8ef">c 447  j1" class="line"jname=n="+e"               "3" class="line""f="+ine" name="L393"> 39 ? -1 : (int) 447  j1" class="line"jname href="+code=t" class="sre9s9ne" nam9"> 428 447  /ef">l = t)cache1" class="line"cache"+co"447"> 447  j1" class="line"jnamecref="+code=i" class="s9 GF(2) wi9h an expected number of 9oluti93>p) {
deg
 381 synhref="+code=bchsynnamen"+code=rows" classhref=href="+code=bchhref=f="+code=l" class="sref">l =  383       ref">deg <= i9> 431p];
tmp;
pdtmp;
 447  count3" class="line"countf="+++c""L447"> 447  GF_N           l =  447  ref">deg <= c = 0;
 39 ? -1 : (int)c++) {
param<9a>[ 39 ? -1 : (int) 381 count3" class="line"countf="+=:LL444"> 444         9a>       9 b/bch.c#L457" id="L4579a">degp 447  finda"L38 rootsed int * 39_elphref="+code=bch_elpntrol"name="L393"> 39_lo3         39_elphref="+code=bch_elpntrol"name="L393"> 39_lo3        i9="L441" class="line" nam9="L4494>j/* di+1 = S(2i+3)+9cd int *<9omment">/* Gaussian elim9natio943j/* di+1 = S(2i+3)+9cef">pd 333
r94/*
 3_"li - de"> 3Thrceived nedeword=and find bit errreflo3me="Ls431" id="L431" class="line" 9="sref">c9/a>-c
m
94f="+cpan>
r 9= deg[rows<9a>[pd                9     95> 333
     failed, ref-EINVALb/f431" id="L431" class="line" 9e"sref">c9/a>                     9     952t
/* f9="L456"> 456        9     95     pan>
param<9ne" name="L457"> 4579     95">m

 3_"li()),ithis funce="L4should be called 9"> 4oneLof431" id="L431" class="line" 9>/* perfo9m elimination on remaini9g row96s,
">deg[f">rows<9 441b408" id="L408" class=c* by provid    @data=and @hrcv_ecc4"nly:431" id="L431" class="line" 9e class="9 href="+code=mask" class9"sref96*/
 3_"li(@"li, @data, @len, @hrcv_ecc, NULL, NULL, @errlo3)431" id="L431" class="line" 9fe="L453"9 464        9     96/*
c9e="L465"> 465       9     962t
 3_"li(@"li, NULL, @len, @hrcv_ecc, @calc_ecc, NULL, @errlo3)431" id="L431" class="line" 9fnt">/* f9eded, store defective ro9 inde96     pan>
">param<9ws" *5id="L355" 2="liba59 m
 9  3_"li(@"li, NULL, @len, NULL, ecc, NULL, @errlo3)431" id="L431" class="line" 9#L369" id9"L369" class="line" name9"L36997s,
rows<9="L370" class="line" nam9="L3797ns
rows<9 3_"li(@"li, NULL, @len, NULL, NULL, @syn, @errlo3)431" id="L431" class="line" 9# class="9"L372" class="line" name9"L37297*/
 333
 3_"li() has successfully href="ed 9"> 4a nasi"ive value,ierrre431" id="L431" class="line" 9#L434" id9"L374" class="line" name9"L37497/*
c9="L375" class="line" nam9="L37972t
/* f9 4errrefis lo3meed /b ecc4(no nemd for431" id="L431" class="line" 9#">param<9m
(9a href="+code=bch" class9"sref98s,
 4errrefis lo3meed /b data=and c>
(9a href="+code=bch" class9"sref98ns
 4pan>em/bc data[errlo3[n]/8c""+c1=n="+n="+c4errlo3[n]=n#37; 8);431" id="L431" class="line" 9Gf">rows<9href="+code=syn" class="9ref">98> 441b408" id="L408" class=c*431" id="L431" class="line" 9G class="9/* di+1 = S(2i+3)+9G"sref">c9href="+code=pp" class="s9ef">p98cc 3_"li-1 : (int) 3_"lif="+cass="sref">inline int a_ilog(struct (struct u/bc8_t3" class="line"u/bc8_tf">a_ilog(struct data-1 : (int)(struct u/bc8_t3" class="line"u/bc8_tf">a_ilog(struct hrcv_ecced int *(struct u/bc8_t3" class="line"u/bc8_tf">a_ilog(struct calc_ecc1" class="line"calc_eccf=rol="L431" class="line" 9G">param<92*(struct synhref="+code=bchsynname="href="lib/bchilog(struct errlo3href="+code=bcherrlo3"+coh/bch.c#L457" id="L4579G/a> <92* 447  BCH_ECC_WORDSed int *l = d991="+code1 namhref="lib/bch.c#L436" id="L4nbitsed int *c<99">p];
 381 errhref="+code=bcherrname="L381"> 381 nrootsed int *d99>tmp;
       u/bc32_t3" class="line"u/bc32_ttmp(struct sum           c<99f">d<44"> 444         9cine" nam9="L394" class="line" nam9="L3999 = 0;

/* di+1 = S(2i+3)+9cline" na9nary Berlekamp-Massey al9orith99 } else {
 383       lenhref="+code=bchlenntronfe"  code=l" class="sref">l =  39nhref="+code=bchnntro-447"> 447  /ef">l = t)ecc_bitsed int *++) {
 447  EINVALed int *param<9 (m];
/* di+1 = S(2i+3)+10opy, 10opy< href="+code=pp" cla10opy>10op} else {
synhref="+code=bchsynnameref="/pre>,82/11/27869c87eb95176f645f10e035ca5d309a6f_3/10opy>">/* di+1 = S(2i+3)+10o1y, 10oef="+code=deg" class="s10oef>10o*/
calc_ecc1" class="line"calc_eccf=roref="+code=t" class="sre10o2y, 10oref="+code=c" class="sr10ore>10o">p];
/* di+1 = S(2i+3)+10o3y, 10oef="+code=deg" class="s10oef>10omask)
data-1 : (int)hrcv_ecced int * 447  EINVALed int *10o = 0;
 3_"lied int * 3_"lif="+code=l" class="sref">l =  381 data-1 : (int) 39NULLa>)-10o++) {
/* di+1 = S(2i+3)+10o8y, 10o(10of="+code1 name2+code=href="libbch_controll =  381 /ef">l = t)ecc_bufed int * 381 calc_ecc1" class="line"calc_eccf=rorr="+code=t" class="sre10o9y, 10o-10of="+code=GF_T" 20358"b/bch.c#L457" id="L457101py, 10/a>+>10/a="+code=GF_T" 20358"=/bch.c#L417" id="L417" cload hrceived ecc refareume it was XORlib/b calc_ecc *="comment">/* di+1 = S(2i+3)+1011y, 10 href="+code=deg" class=10 hr>10/*/
hrcv_ecced int *10/">p];
l =  381 /ef">l = t)ecc_buf21" class="line"ecc_buf2"+co="L381"> 381 hrcv_ecced int *lculated ecc4*="comment">/* di+1 = S(2i+3)+1014y, 10> =  =>10/>tmp;
 39ecc_wordsed int *deg <= 10/ = 0;
l = t)ecc_bufed int * 447  ref">deg <= l = t)ecc_buf21" class="line"ecc_buf2"+co"447"> 447  ref">deg <=  415        10="L>10/ } else {
l = t)ecc_bufed int * 447  ref">deg <=  41610ne">10/++) {
sum           10/f="+code=GF_T" 20358"href="liiiiiiic#=/bch.c#L417" id="L417" cnoierrreffound4*="comment">/* di+1 = S(2i+3)+102py, 10*10*;
 444         10*1y, 10; 10**/
10*">p];
l =  381 /ef">l = t)ecc_bufed int * 381 /ef">l = t)synhref="+code=bchsynnamer444"> 444         10*3y, 10ne" name="L422"> 42210ne">10*>tmp;
l = t)synhref="+code=bchsynname444"> 444         10*4y, 10lass="line" name="L423">10las>10*>tmp;
10* 374}
10* } else {
 381 errhref="+code=bcherrnamene"               ce" nam_errre_lo3mere_name="L335ed int *l =  381 synhref="+code=bchsynnamer444"> 444         10*7y, 10"L426" class="line" name10"L4>10*        }
errhref="+code=bcherrnamenfe"  0ref="+code=t" class="sre10*8y, 10="L427" class="line" nam10="L>10*f="+code1 name2+code=447"> 447  nrootsed int * 447  finda"L38 rootsed int *l = l = t)elphref="+code=bchelpntrol"name="L393"> 39errlo3href="+code=bcherrlo3"+coh444"> 444         10*9y, 10"> 428 >10*f="+code=GF_T" 20358"#"L403" class="lineerrhref="+code=bcherrnamen!"L447"> 447  nrootsed int * 444         1031y, 10turn the number of found10tur>10h1tmp;
 4>10h2       }
errhref="+code=bcherrnamenfe"  0ref="+code=t" class="sre1033y, 10 href="+code=rows" class10 hr>10h>tmp;
/* di+1 = S(2i+3)+1034y, 10 href="+code=nsol" class10 hr>10h>tmp;
lenhref="+code=bchlenntro*8)+code=bch" class/ef">l = t)ecc_bitsed int *10h = 0;
errhref="+code=bcherrnamerf="+code=r" clasref">deg <= 10h } else {
errlo3href="+code=bcherrlo3"+co"447"> 447  ref">deg <= 10h++) {
 444         1038y, 10a>[[>10hf="+code1 name2+code=href="liiiiiiiiibreakref="+code=i" class="s10h9y, 10="L438" class="line" nam10="L>10hf="+code=GF_T" 20358"href="lib/bch.c#L457" id="L457104py, 1010 = 0;
 447  ref">deg <=  447  errlo3href="+code=bcherrlo3"+co"447"> 447  ref">deg <= 10<*/
 447  ref">deg <= errlo3href="+code=bcherrlo3"+co"447"> 447  ref">deg <= errlo3href="+code=bcherrlo3"+co"447"> 447  ref">deg <=  444         1042y, 10="L441" class="line" nam10="L>10<">p];
/* Gaussian elim10omm>10<>tmp;
10<>tmp;
 381 errhref="+code=bcherrnamen:l-447"> 447  EBADMSGed int *>10<2t 447  EXPORT_SYMBOL_GPLed int * 3_"li-1 : (int) 3_"lif="+h444"> 444         1047y, 10nd suitable row for elim10nd >10<7374}
10<">m
, 10ref="+code=mask" class="10ref>10
, 10= 10= ="+cpan>
/* di+1 = S(2i+3)+1051y, 10a>[[>10=*/
l = inline int a_ilog(struct [>10=">p10=>tmp;
 381 x1" class="line"xnamene"1444"> 444         1054y, 10 453                10 45>10=>tmp;
 444         1055y, 10= 10= 374}
/* di+1 = S(2i+3)+1057y, 10="L456"> 456        10="L>10=        }
khref="+code=bchkntro=!"L41u=n="+n="+code=l" class="sGF_M           l = /* di+1 = S(2i+3)+1058y, 10ne" name="L457"> 45710ne">10=f="+code1 name2+code=href="l-1444"> 444         1059y, 10 href="+code=rem" class=10 hr>10=/*GF_N           l = deg <= [>10m">p];
l = t)href=_tab">l =  447  ref">deg <=  444         1062y, 1010m">p];
l = t)hrlog_tab">l =  447  x1" class="line"xname]n"L.c#L436" id="L4ref">deg <= 10m>tmp;
/* di+1 = S(2i+3)+1064y, 1010m>tmp;
 40f="+if="+2^m-1) #="comment">/* di+1 = S(2i+3)+10m5y, 10="L464"> 464        10="L>10m = 0;
 444         1066y, 10e="L465"> 465       10e=">10m } else {
 444         1067y, 10eded, store defective ro10ede>10m++) {
/* di+1 = S(2i+3)+1068y, 10ws" *5id="L355" 2="liba510ws">10mf="+code1 name2+code=href="libbch_control 444         1069y, 10code=         Xu1href=> 10cod>10mf="+code=GF_Tb/bch.c#L457" id="L457107py, 10"L369" class="line" name10"L3>10"L} else {
 381 /ef">l = t)href=_tab">l =  447  GF_N           l =  444         1071y, 10="L370" class="line" nam10="L>10"1} else {
 381 /ef">l = t)hrlog_tab">l =  444         10"2y, 1010"2*10">tmp;
 444         1074y, 10 href="+code=deg" class=10 hr>10"4/a> b/bch.c#L457" id="L4571075y, 10"L374" class="line" name10"L3>10" 374}

, 1010"     pan>
 ing431" id="L431" class="line" 1078y, 1010"">m
/* di+1 = S(2i+3)+1079y, 10"L378" class="line" name10"L3>10"9/
l = inline int a_ilog(struct (struct u/bc32_t3" class="line"u/bc32_ttmp(struct  -1 : (int), 10a href="+code=bch" class10a h>10a >p10a1} else {
 381 j1" class="line"jname="L381"> 381 b">l =  381 d         444         1082y, 10href="+code=syn" class="10hre>10a">p];
 39u/bc32_t3" class="line"u/bc32_ttmp(struct data-1 : (int) 381 lohref="+code=bchloname="ilog(struct tab">l =  444         1083y, 1010a>tmp;
l = l = t)ecc_bitsed int *l = t)ecc_bitsed int *, 10="L386" class="line" nam10="L>10a7>p];
 39memset3" class="line"memsetf="+code=l" class="sref">l = t)mod8_tab3" class="line"mod8_tabL380de0, 4*256> 383       lhref="+code=bchl="li*sizeof(ilog(struct t)mod8_tab3" class="line"mod8_tabL380)h444"> 444         1088y, 102*10a">m];
10af="+code=GF_Thref="lib/bch.c#L396" id="L396" class="line"04a"lib/bch.c#L396" id="L396" class="linf="+ 256rf="+code=r" clasref">deg <= /* di+1 = S(2i+3)+1091y, 10ref="+code=deg" class="s10ref>10=">p];
l = l = l = p];
/* di+1 = S(2i+3)+1093y, 10ref="+code=deg" class="s10ref>10=mask)
l = l = t)mod8_tab3" class="line"mod8_tabL380 +f="lib/bch.c#L396b">l = deg <=  383       lhref="+code=bchl="li444"> 444         1094y, 10href="+code=c" class="sr10hre>10=>tmp;
deg <=  383       b">l =  444         1095y, 10="L394" class="line" nam10="L>10= = 0;
 444         1097y, 1010=++) {
/* di+1 = S(2i+3)+1098y, 10 (10=f="+code1 name2+code=href="liiiiiiiiibbch_control 447  d         444         1099y, 10>--<>10=f="+code=GF_T" 20358"href="liiiiiiic#href="lib/bch.c#L396j1" class="line"jname="L04a"lib/bch.c#L396j1" class="line"jname=n="+h.c#L436" id="L4ecclenhref="+code=bchecclenntro+c447"> 447  j1" class="line"jname href="+code=t" class="sre11opy, 11opy< href="+code=pp" cla11opy>110;
d         381  -1 : (int) 447  j1" class="line"jname]=n="+n="+c4bch_controld         444         1101y, 11oef="+code=deg" class="s11oef>11o*/
j1" class="line"jname 1=n="+h.c#L436" id="L4"lenhref="+code=bchplenntrore?44"> 444         1102y, 11oref="+code=c" class="sr11ore>11o">p];
 447  j1" class="line"jname+1]sclasfe"  c31-447"> 447  d         444         1103y, 11oef="+code=deg" class="s11oef>11omask)
l =  447  j1" class="line"jname]="+code=rows" classh81" class="line"h name|bbch_control 444         1104y, 11oref="+code=c" class="sr11ore>11o>tmp;
11o = 0;
11o++) {
11of="+cb/bch.c#L457" id="L45711o9y, 11o-110/*>111 ="+cpan>
, 11 href="+code=deg" class=11 hr>111ns
, 11111> 441b408" id="L408" class=c*="comment">/* di+1 = S(2i+3)+1113y, 11ode=elp_copy" class="sre11ode>11/mask
l = inline int a_ilog(struct , 11> =  =>11/>tmp1115tmp;
 447  GF_M           l =  444         1116y, 11="L415"> 415        11="L>11/ } else {
 381 j1" class="line"jname="L381"> 381 rhref="+code=bchrname444"> 444         1117y, 11ne" name="L416"> 41611ne">11/++) {
 381 x1" class="line"xname="L381"> 381 83" class="line"yname="L381"> 381 remain   href="+code=bchremain   name="L381"> 381 akhref="+code=bchakntro="L0de=a_log" class="x81" class="line"xi"+co"447"> 447  m           m];
11/f="+code=GF_Tb/bch.c#L417" id="L417" cfind k s.t. Tr(a^k)="L1=and 0=n="+e"k=n="+hm *="comment">/* di+1 = S(2i+3)+112py, 11*112 ="+code1 namhref="lib/bch.c#L396" id="L396" class="line"04a"lib/bch.c#L396" id="L396" class="linf="+ bch_controlm           deg <= 11**/
11*">p];
l = deg <=  444         11*3y, 11ne" name="L422"> 42211ne">1123j/* di+1 = S(2i+3)+1124y, 11lass="line" name="L423">11las>112>tmp;
112 = 0;
l = t)href=_tab">l =  447  ref">deg <=  444         11*6y, 11112 } else {
112++) {
 428 >112f="+code=GF_Tb/bch.c#L417" id="L417" cfind xi, i=0..m-1 suchithatixi^2+xi="La^i+Tr(a^i).a^k *="comment">/* di+1 = S(2i+3)+113py, 11h an expected number of 11h a>113L} else {
 381 remain   href="+code=bchremain   name="L               m           /* di+1 = S(2i+3)+1131y, 11turn the number of found11tur>1131} else {
 381 memset3" class="line"memsetf="+code=l" class="sx81" class="line"xi"+code0, sizeof(ode=l" class="sx81" class="line"xi"+co)h444"> 444         1132y, 11> 43111h>tmp;
 447  GF_N           l =  381 remain   href="+code=bchremain   name="L381"> 381 x1" class="line"xname href="+code=t" class="sre1134y, 11 href="+code=nsol" class11 hr>11h>tmp;
l =  444         1135y, 11"L434" class="line" name11"L4>11h = 0;
deg <= 11h } else {
 381 rhref="+code=bchrname="L               hrlog">l = l =  444         1137y, 11 href="+code=mask" class11 hr>11h++) {
x81" class="line"xi"+co"447"> 447  rhref="+code=bchrname]ref="+code=t" class="sre1138y, 11a>[[>11hf="+code1 name2+code=href="liiiiiiiii               /ef">l = t)xi_tab">l =  447  rhref="+code=bchrname]n"L.c#L436" id="L4x1" class="line"xname444"> 444         11h9y, 11="L438" class="line" nam11="L>11hf="+code=GF_T" 20358"href="liiiiiiiii               x81" class="line"xi"+co"447"> 447  rhref="+code=bchrname]ne"1444"> 444         114py, 1111 = 0;
 381 remain   href="+code=bchremain   name--444"> 444         1141y, 11lt; 11<*/
 381 db -1 : (int)"xn#37;dne"n#37;x\n""commen="L381"> 381 rhref="+code=bchrnamede=a_log" class="x1" class="line"xname)444"> 444         1142y, 11="L441" class="line" nam11="L>11<">p];
/* Gaussian elim11omm>114mask)
114>tmp;
>114 } else {
/* di+1 = S(2i+3)+1148y, 11114f="+code1 namhref="lL381"> 381 remain   href="+code=bchremain   name=? -1 :LL444"> 444         11<9y, 11ref="+code=mask" class="11ref>1111= ="+c/bch.c#L457" id="L4571151y, 11a>[[>11=*/
(struct (struct err3" class="line"errnamer="+code=t" class="sre1152y, 11a>[[>11=">p11=>tmp;
(struct ptr3" class="line"ptrntroref="+code=i" class="s1154y, 11 453                11 45>115f">d<44"> 444         1155y, 11= 115 = 0;
(struct ptr3" class="line"ptrntron"L.c#L436" id="L4kmallo3href="+code=bchkmallo3f="+code=l" class="ssize3" class="line"sizenamede447"> 447  GFP_KERNELed int * 444         1156y, 11/a>                     11/a>>115 } else {
(struct ptr3" class="line"ptrntron""L.c#L436" id="L4NULLa>)- 444         1157y, 11="L456"> 456        11="L>115++) {
 444         1158y, 11ne" name="L457"> 45711ne">115f="+code1 namhref="lL381"> 381 ptr3" class="line"ptrntroref="+code=i" class="s1159y, 11 href="+code=rem" class=11 hr>115f="+cb/bch.c#L457" id="L457116py, 11m elimination on remaini11m e>116 ="+c/bch.c#L457" id="L45711m1y, 11a>[[>116ns
, 11116> 441b408" id="L408" class=c* ne" namegener trefname="L335 hrefgiven (m,t) parclaters.431" id="L431" class="line" 1163y, 11 href="+code=mask" class11 hr>116*/
/* di+1 = S(2i+3)+1164y, 1111m>tmp
 381 u/bc32_t3" class="line"u/bc32_ttmp(struct ce" nam_gener tre_name="L335ed int *inline int a_ilog(struct , 11="L464"> 464        11="L>11m f="+code=t" class="sre1166y, 11e="L465"> 465       11e=">11m } else {
 447  GF_M           l =  444         1167y, 11eded, store defective ro11ede>11m++) {
 447  GF_T           l =  444         1168y, 11ws" *5id="L355" 2="liba511ws">11mf="+code1 nam/bch.c#L436" id="L4n">l =  39err3" class="line"errnamene"L444"> 444         1169y, 11code=         Xu1href=> 11cod>11mf="+code=GF_Thref="lib/bch.c#L436" id="L481" class="line" name="L381"> 381 j1" class="line"jname="L381"> 381 nbitsed int * 381 rhref="+code=bchrnamede=a_log" class="wordhref="+code=bchwordnamedeilog(struct rootsed int *11"L} else {
inline gf_"L383" class="line"gf_"L38f">a_ilog(struct  -1 : (int) 381 u/bc32_t3" class="line"u/bc32_ttmp(struct  en"L383" class="line"gen"L38"+cor="+code=t" class="sre1178"+cor="+c"gen"L3int * 447o ,58/a> <=  3_" class="sref">efnlse1line"u/bc3+Hrprprprprprprprprprprp=" "> 3_" class="sref">efnlse1line"u/bc3+Hrprprprprprprprprprprpass="sprprprprprprprprpass="eGsprprprrprprprprprprprprpas="L447"> 447  GF_l =  447  GF_),rol10"4/a> b/bch.c#1457" 174lass="sref">efnlse1line"u/bootsf="+r="+code=t" class="srprprp=" "> 3_" class="sref">efnlse1line"u/bc3+Hrprprprprl =  39nhref="+code=bchnntro-447"> 447  /ef">+1)ct      ame10"L3>10" 374}
 3_" class="sref">efnlse1line"u/bc3+Hrprprprprprprprprprprpasde=bchDIV_ROUND_UPf="+code=l" class="sref">l =  447  GF_l =  447  GF_ass="srct     nam10="L>10"2t
10"     pan>
, 11a>[10"">m
 447  nrootsed int * 447l = 10"9/
 3_" claLLf="+h44"> 444        e1178"+cor="+c"gen"L3intode=bch" c1ass10a h>10a >p 3_" clafiniscoine" name="L39finisc    e1178"+cor="+c"gen"L3intoss="line" ass10a h>10a1} else {
p];
 44710a>tmp;
, 10ref="+cod1t" class="1ref10ode>10a>tmp;
efnlse1line"u/bmemsetf="+code=l" class="sx81" class="line"xi"+ootsf="+r="+code=t" class="srpass="l =  39nhref="+code=bchnntro-447"> 447  /ef">+1)ct m            447  GF_>deg <=  381 444         114py, 1110a">m];
l = l =  444       ,"2ef="+code=bch_co="L               hrl)e1178"+cor="+c"gen"L3intt   Xu1hreflas102*<>10af="+code=GF_T1ref="18href="liiiiiiiii     71032y, 10> 4311ass="line"1nam10="L>10="} else {
, 10> 4311ass="line" ="s10ref>10=">p];
, 10ref="+cod1e=c" class1"sr10hre>10=">p];
efnlse1line"u/bc3+Hrprprprprprprprprhref="+code=bchnntro">efnlse1line"u/ref">d0      114py, 1110=>tmp;
GF_N           l = deg <=  444        sre10m1y, 10a>[10= } else {
, 10ref="+cod1eode=bch" 1ss=1010=++) {
l = t)href=_tab">l =  447  ref">deg <=  444         11*6y, 1110=f="+code1 nam12+cod1=href="liiiiiiiiibbch_controlefnlse1line"u/ref">defnlse1line"u/bc3+Hrprprprprprprprprhref="+code=bchnntro"+co403" class="linedata-> 44    114py, 11 2"+code=pp"2cla11opy>110;
efnlse1line"u/ref">defnlse1line"u/b]="+code=rows" classh81qrhref="+code=bchgf_mul8f">a_ilog(strmulef">l =  444       ,"efnlse1line"u/bc3+Hrprprprprprprprprhref="+code=bchnntro">efnlse1line"u/ref">defnlse1line"u/b]="+code=rows" classh8          efnlse1line"u/ref">defnlse1line"u/b]="+code=rows" classh-1  11*6y, 11, 1110=">p];
efnlse1line"u/ref">d0    href="+code=bchgf_mul8f">a_ilog(strmulef">l =  444       ,"efnlse1line"u/bc3+Hrprprprprprprprprhref="+code=bchnntro">efnlse1line"u/ref">d08          10=>tmp;
11o = 0;
, 10> 4312a6s="line"2nal10nar>10= } else {
11o++) {
 447  /ef">sumefnlse1line"u/bc3+Hrprprprprprprprprhref="+code=bchnntro"+co403" class="linedata-+  114py, 1111of="+cb/bch.c#2457" 208457" id="L45"+code=bchnntrone"04a"lib/bch.c#L396" id=114py, 11-<>10=f="+code=GF_T2=i" c2ass="s111py, 11/a>+
 447  /ef">slass="sre1033y, 10 href="+c2de=deg" cl2ss=11 hr>111ns
l = lenhref="+code=bchlen-447"> 447  /ef">slass=321 : 32 :5"+code=bchnntro-447"> 447  /ef">=114py, 11111> 441b408" id2"L40821href="lihref="lihref=1" class="line"jname="L0de=a_log" class="sum           (struct rooj1" class="line"jname=n="+h.c#L436" id="L4m           leclass="line"jname hr="+code=t" class="srere1136y, 11a href="+2py" class=2sre11ode>11/mask
efnlse1line"u/ref">defnlse1line"u/b-447"> 447  /ef">lo3href="+code=bch]="+code=rows" classh8t11m5y, 11="L464"> 2f="+code=d2 cl11> =>11/>tmp         444       =114py, 111115tmp;
11/ } else {
 444       ++    href="+code=bchrdnamedeilog(struct roo=114py, 1111ne">11/++) {
 447  /ef">s-sed int * 447  err=114py, 11111">m];
 42811/f="+code=GF_T2/bch.2#L417" id="L417l = t)href=_tab">l =  428112 ="+code1 nam2ref="22"L45711m1y, 11a>[11**/
11*">p];
 447l =  4222/a>11ne">1123j/* di21 = S22class="sref">efnlse1line"u/bkfreamede447"> 447l = 11las>112>tmp;
112 = 0;
112 } else {
 428112++) {
, 11 >112f="+code=GF_T2/bch.22b/bch.c* gener te Galois fieldinit_a h -dinitialize a BCH1" claer/declaer"line" 1162y, 1123b/bch.c*="comment">/* di+1 =  @m:f="lib/bchGalois field ucter,t check=bedin the range 5-1b/bine" 1162y, 111131} else {
23b/bch.c# build a basemhreffact@t:f="lib/bchmaximum err" ccorrecrce="capability err =t" cline" 1162y, 11 4>1132*, 11 4222ass11 hr>11h>tmp;
/* di+1 = cline" 1162y, 1111h>tmp;
, 1111h = 0;
 gf_"Lure_rhrsuccessful,      otherwiine, 1111h } else {
, 1111h++) {
, 11[>11hf="+code1 nam22+cod23b/bch.c*="comment">/* di+1 = 1" class=/declass=;hmake sure_anyw*b+dght=this funcrce="g))c*a time criticine, 1111hf="+code=GF_T2 203523b/bch.c* gener te Galois fieldpath. Usughty errit_a h()t check=beddghted e="module/dreLorerrit *="e, 1111 = 0;
/* di+1 =  frea_a h()t check=beddghted *b+releremememory e="exit="line" 1163y, 11 href="+c2f="+code=m2 cl11lt;>11<*/
, 11 href="+c2fode=tmp" 2nam11="L>11<">p];
, 11 href="+c2f422"> 4222lim11omm>114mask)
/* di+1 = m@40f=ruct , uc leterrit_a h()tuse t"  defaultffdegremem ="line" 1163y, 11 href="+c2f="+code=d2ss=11114>tmp;
, 11 href="+c2fe=elp" cl2="s11ref>114 = 0;
 io a newly Hrprpated"line" 1163y, 11 href="+c2fode=deg" 2 cl11/a>>114 } else {
 gf_"Lure, cod lengtherr =yt31"is s.431"byememb"> @code=yt31"of"line" 1163y, 11 href="+c2fs="line" 2lim11nd >1147>p];
, 11 href="+c2fss="line"2ss=11114f="+code1 nam2ref="24b/bch.c*="comment">/* di+1 = S(2i+3)+1079y, 10"L378" cl2=mask" cla2s="11ref>11a_ilog(struct  444   rit_a hef">l           447  GF_,3" class="line"tL380="L447"> 447  GF_," id="L481" class="line" name40f=ruct "L447"> 44740f=ruct ="sr)1079y, 10"L378" cl2"+code=p" 2las11= <>11= ="+c/bch.c#L257" i25s="sre1081y, 10a href="+2="+code=r"2cla11a>[>11=*/
 444         1169y, 11code=    2="+code=p"2cla11a>[>11=">p 381 j1" class="line"jnameructf="+r="+code=t" ructf="sre1178"+cor="+c"gen"L3in2code=tmp" 2las1111=>tmp;
efnlse1line"u/be"u/bc32_ttmp(struct  en"L383" class="line"gen"L38"+cor="+code=t" class="sre1178"+cor="+c"gen"L3in2          2   11 45>115f">d<44"> 4442/a>  25href="lihref= int a_ilog(struct  3_" claLLf="+h44"> 444        e1178"+cor="+c"gen"L3in2"+code=r" 2las11= <>115 = 0;
, 10="L375" c2          2   11/a>>115 } else {
 447 in_=mmenprp5e1178"+cor="+c"gen"L3in2"s="line" 2   11="L>115++) {
 447 ax_=mmenprp15e1178"+cor="+c"gen"L3in2"ss="line"2/a>11ne">115f="+code1 nam2ref="25b/bch1119y, 11115f="+cb/bch.c#2457" 25L417" id="L417" cfind xi, i=0..m-1 sucdefaultffust beLoffdegremem s= S(2i+3)+1079y, 10"L378" cl2ion on rem2ini11m e>116 ="+c/bch.c#L257" i26f">inline g/bc32#L436" id="L4t3" class="line"tL38040f=ruct ef=_tab"+co"447"> 440f=ruct ef=_="srd    e1081y, 10a href="+2="+code=p"2cla11a>[>116ns
l0x25,l0x43,l0x83,l0x11d,l0x211,l0x409,l0x805,l0x1053,l0x201b,1081y, 10a href="+2="+code=p"2ss=11116> 441b408" id2"L40826href="lihref="lihref=0x402b,l0x8003,1081y, 10a href="+2=ode=tmp" 2ass11 hr>116*/
}e1178"+cor="+c"gen"L3in2code=tmp" 2las1111m>tmp
 26     1155y, 11=     2   11="L>11m f="+code2t" cl2ss="sr#if : (int) 444l =    2   11e=">11m } else {
(struct ptr3" l =  447  GF_ !href="+code=bchlenCONFIG_=l" CONST_="+code=l" classCONFIG_=l" CONST_=="sr)) ||ref="+code=bchlen="L447"> 447  GF_T!href="+code=bchlenCONFIG_=l" CONST_="+code=l" classCONFIG_=l" CONST_=="sr))ere1136y, 11a href="+2e defectiv2 ro11ede>11m++) {
l =  _ERRref="+code=i" c/a> _ERRref=""xn#37;dne"n#37;x\n&qua h " claer/declaer was #L4figured *b+support  381 rhre1136y, 11a href="+2ess="line"2ba511ws">11mf="+code1 nam2bch.c26href="liiiiiiiiibbch_control"xn#37;dne"n#37;x\n&qu431" class m=t;"com, t=t;"com only!"> 381 rhref1136y, 11a href="+2ee=rem" cl2=> 11cod>11mf="+code=GF_T2ref="26href="liiiiiiic#href="lib/bcf="+code=bchlenCONFIG_=l" CONST_="+code=l" classCONFIG_=l" CONST_=="srclass="line"jnameCONFIG_=l" CONST_="+code=l" classCONFIG_=l" CONST_=="sr)e1178"+cor="+c"gen"L3in2ss="line" 2ame11"L3>11"L} else {
 3_" clafais="sref">a_ilog27L457" id="L4571032y, 10> 4312 * 3_2 class="sref">r3" l =  447  GF_             447 in_=mmen) ||ref="+code=bchlen="L447"> 447  GF_  g          447 ax_=mmen))1079y, 10"L378" cl2 ode=tmp" 2ss=10 hr>10"4/a> b/bch.c#2457" 27href="lihref="lib/bch."l431" id="L431" class="line" 1162y, 1110" 374}
 ih ne15"are_anywcurr trly+supported/a> rhre1136y, 11a href="+2 65   2nam10="L>10"2t
, 1110"     pan>
, 1110"">m
/* di+1 =nnnnnnnnnnnnnnnn*S(2i+3)+1079y, 10"L378" cl2    Xu1hre2ame10"L3>10"9/
 3_" clafais="sref">a_ilog10a >p, 11a>[10a1} else {
/s= S(2i+3)+1079y, 10"L378" cl2e=syn" cla2s="10hre>10a">p];
r3" l =  447  GF_T     1) ||ref="+code=bchlen="L447"> 447  GF_l =  447  GF_  g  hreass="sj1" class="line"jname)nfass=lass="!bch_cont-1)))1079y, 10"L378" cl2code=elp" 2las1010a>tmp;
, 10"L378" cl2eode=tmp" 2ref10ode>10a>tmp;
 3_" clafais="sref">a_ilog    2ref10ode>10a5tmp;
, 10="L375" c2e=pp" clas2="s10hre>10a6374}
errhref="+code=bcherr40f=ruct "L447"> 44740f=ruct ="srLLa>0)1079y, 10"L378" cl2css="line"2las102*<>10a">m];
 44740f=ruct ="srLLlass="line"tL38040f=ruct ef=_tab"+co"447"> 440f=ruct ef=_="srdass="line"jname)nfass=lass="!bch_con         447 in_=mmen  11*6y, 11, 11/a>+ 3_" clakzmallo3f="+code=l" clazHrprprprprt  444         1156y, 11/a>      2ass="line"2="s10ref>10=">p];
)- 444         1157y, 11="L456"> 2e=c" class2"sr10hre>10=">p];
 3_" clafais="sref">a_ilog, 11lass="lin2e=c" class2"sr10hre>10=>tmp;
efnlse1line"u/b"+co class="sref">t)href=_tab">l =  447  GF_M           /* di+1 = S(2i+3)+1131y, 11turn the 2ass="line"2nam10="L>10= = 0;
t)href=_tab">l =  447  GF_T            447  GF_>1131y, 11turn the 2a=pp" clas2 al10nar>10= } else {
t)href=_tab">l =  447  /ef">sumass="sj1" class="line"jname)nfass=lass="!bch_cont-1>1131y, 11turn the 2aode=bch" 2ss=1010=++) {
l =  447  GF_l =  447  GF_s="sr>1131y, 11turn the 2ass="line"2las10 (<>10=f="+code1 nam22+cod298457" id="L45"+code=bchnntro"+co class="sref">t)href=_tab">l =  444l =  447  GF_l =  447  GF_s=8r>1131y, 11turn the 2a   Xu1hre2cla10>-<>10=f="+code=GF_T2 203529L417" id="L417l = t)href=_tab">l =  447  ref">prprp=" "> 3_" class="sref">efnlse1line"u/bc3+Hrprprprprl1+class="line"ptr"+co class="sref">t)href=_tab">l =  447  /ef">)ct t)href=_tab">l =  447  ref">),rol110;
l =  447logef=_ef">prprp=" "> 3_" class="sref">efnlse1line"u/bc3+Hrprprprprl1+class="line"ptr"+co class="sref">t)href=_tab">l =  447  /ef">)ct t)href=_tab">l =  447logef=_ef">),rol10=">p];
t)href=_tab">l =  4=od8ef=_="sr T           efnlse1line"u/bc3+Hrprprprpr"+code=bchnntroructf="+r="+code=t" ructf="sr*1024ct t)href=_tab">l =  4=od8ef=_="sr),rol10=">p];
t)href=_tab">l =  444efnlse1line"u/bc3+Hrprprprpr"+code=bchnntroructf="+r="+code=t" ructf="sr*t t)href=_tab">l =  44410=mask)
efnlse1line"u/b"+co class="sref">t)href=_tab">l =  444efnlse1line"u/bc3+Hrprprprpr"+code=bchnntroructf="+r="+code=t" ructf="sr*t t)href=_tab">l =  44410=>tmp;
efnlse1line"u/b"+co class="sref">t)href=_tab">l =  447  rhref "li           efnlse1line"u/bc3+Hrprprprpr"+code=bchnntro="L447"> 447  GF_lt t)href=_tab">l =  447  rhref),rol10= = 0;
t)href=_tab">l =  447  sy-truct ptr3"           efnlse1line"u/bc3+Hrprprprpr2ef="+code=bch_co""L447"> 447  GF_lt t)href=_tab">l =  447  sy-truc),rol10= } else {
t)href=_tab">l =  447efnlse1line"u/bc3+Hrprprprpr2ef="+code=bch_co""L447"> 447  GF_lt t)href=_tab">l =  44710=++) {
t)href=_tab">l = efnlse1line"u/bc3+Hrprprprprl =  447  GF_+1)ct  447"gf_"L3_deg1/bch),rol10=f="+code1 nam3457" 30b/bch1119y, 11-<>10=f="+code=GF_T3=i" c30L417" id="L41 id="L396" class="line"04a"lib/bch.c#L396" id="L396" class="linf="+ bch_controlGF_N           t)href=_tab">l =  447_"L3_2=="sreedeg <= 
t)href=_tab">l =  447_"L3_2=="srdeg <=  444        prprp=" "> 3_" class="sref">efnlse1line"u/bc3+Hrprprprprprprprprprprpass="sprprprprprprprprpass="eGsprprprrprpr2ef="+code=bch_co""L447"> 447  GF_),rol111ns
111> 441b408" id3"L408312lass="sref">r3" class="line"errnamer="+code=t" class="sre11*6y, 1111/mask
 3_" clafais="sref">a_ilog, 11= 1115tmp;
 444       rp=" "> 3_" clasr   _"gfing431>efnlse1line"u/br   _"gfing431rprpr"+code=bchnntro"+co class="sref">t)hKERNELed int * 44740f=ruct ="sr)e1178"+cor="+c"gen"L3in3f6code=pp"3   11="L>11/ } else {
(struct ptr3" class="line"pt, 1111/masklass="line2/a>11ne">11/++) {
 3_" clafais="sref">a_ilog111">m];
, 1111/f="+code=GF_32/bch315L417" id="L417" cfind xi, i=0..m-1 sutuse hrefgiven (m,t) parclateme="L3v35s1" classp ing431= S(2i+3)+1093y, 10ref="+co32+code=i" 32ass11*112 ="+code1 na32ref=32081 remain   href="+coder"gen"L38"+cor="+code=t" class="srprprp=" "> 3_" clme="L335ed int *inlinet)r)e1178"+cor="+c"gen"L3in2"+code=j"32las11; <>11**/
 444         1157y, 11="L456">32"ode=tmp"32las112-<>11*">p];
 3_" clafais="sref">a_ilog 4232/a>11ne">1123j/* d321 = 329i+3)+1124y, 11lass="li32L="+code=323">11las>112>tmp;
efnlse1line"u/bbr   4=od8ef=g431>efnlse1line"u/br   4=od8ef=g431rprpr"+code=bchnntro"+co class="sref">t)hKERNELed int *112 = 0;
 447l = 112 } else {
, 10="L386" 32ss="line"32ame11"L4>112++) {
 444       rp=" "> 3_" clasr   _de2_egre1>efnlse1line"u/br   _de2_egrenet)r)e1178"+cor="+c"gen"L3in2"8code=pp"2nam11="L>11*f="+code1 na32/bch328/a>(struct ptr3" class="line"pt, 1111/mask >112f="+code=GF_32/bch327href="liiiiiiiii     gotoprp=" "> 3_" clafais="sref">a_ilog113L} else {
, 11a>[1131} else {
t) e1178"+cor="+c"gen"L3i32"ode=tmp"32"co11> 4>1132* 44732t422"> 4232ass11 hr>11h>tmp;
 3_" clafais="sref">a_ilog, 11a>[efnlse1line"u/ frea_a s="sref">a_ilogt)r)e1178"+cor="+c"gen"L3in2te=elp" c32ame11"L4>11h = 0;
 444        e1178"+cor="+c"gen"L3i32tode=deg"32ass11a h>11h } else {
, 11"> 42811h++) {
 444 444   rit_a hef">l    8"+cor="+c"gen"L3in2te=elp=pp"2nam11a>[>11hf="+code1 nam22+co323b/b331119y, 1111hf="+code=GF_T2 203323b/b3h.c* gener te Galois fieldpaine" 1162y, 1111 = 0;
/* di+1 =  frea__a h()t c -_a h( gf_"truct > gf_"Lure, cod" 1162y, 1111<*/
, 11p];
, 10ref="+co32+code> 4222lim13omm>114mask)
a_iloga_ilog(struct , 11="L464"> 464114>tmp;
, 11a href="+2e de3p" cl2="s13ref>114 = 0;
 381 j1" class"+cor="+c"gen"L3in2te=eldeg" 2 cl13/a>>114 } else {
, 10="L386" 32ss="line" 2lim13nd >1147>p];
errhref="+code=bcherr40f=r 114f="+code1 nam2ref=324b/b34 447  nrootsed int * 447l = t)href=_tab">l =  447  ref">),rol<"+cor="+c"gen"L3in2te=eldclas2nam13ref>11 447l = t)href=_tab">l =  447logef=_ef">),rol<"+cor="+c"gen"L3in2te=ele=p" 2las13= <>11= ="+c/bch.c#L257" 325s="35"lib/bch.c#L381""+code=bchnntro"+co mede447"> 447l = t)href=_tab">l =  4=od8ef=_="sr),rol<"+cor="+c"gen"L3in2te=ele=j"32und11a>[>11=*/
l =  447l = t)href=_tab">l =  444[>11=">p 447l = t)href=_tab">l =  44411=>tmp;
 447l = t)href=_tab">l =  447  rhref),rol<"+cor="+c"gen"L3in2te=elede=d2ss=13 45>115f">d<44"> 4442/a> 325hre35"lihref="lib/bch."l431  447l = t)href=_tab">l =  447  sy-truc),rol<"+cor="+c"gen"L3in2te=ele" cl2="s13= <>115 = 0;
 447l = t)href=_tab">l =  447>115 } else {
 447l = t)href=_tab">l = 13ne">115f="+code1 nam2ref=325b/b35 447  nrootsed inL396" class="line"04a"lib/bch.c#L396" id="L396" class="linf="+ bch_controlGF_N           t)href=_tab">l =  447_"L3_2=="sreedeg <= 115f="+cb/bch.c#2457"325L4135"liiiiiiic#href="lib/bcf="+c"line"xname"gen"mede447"> 447l = t)href=_tab">l =  447_"L3_2=="srdeg <=  444        prprp<"+cor="+c"gen"L3in2te=eln rem2ini13m e>116 ="+c/bch.c#L257" 326f">3611m1y, 11a>[[>116ns
l0x25,line"xname"gen"mede447"> 447l = t)href=_<"+cor="+c"gen"L3in2te=elnmp"32"co11116> 441b408" id2"L40326hre3="lihref="lihry, 11"> 428116*/
, 11"> 42811m>tmp
326   3 1155y="line"ptEXPORT_SYMBOL_GOf="+h44"> 444a_ilog11m f="+code2t" c32ss="361076y, 10="L375" c2e=pp3a>   2   13e=">11m } else {
3structe=bchnntro"rit_MODULE_LICENS bch_controARRAYMODULE_LICENS "+codexn#37;dne"n#37;x\n&qu431" /ar/a> rhref1136<"+cor="+c"gen"L3in2te=elnne" 2lim13ede>11m++) {
 _MODULE_AUTHO""+codexn#37;dne"n#37;x\n&qu431" Iv#37Djelic     iv#3.djelic@parrot.comab">/a> rhref1136<"+cor="+c"gen"L3in2te=elnine"2/a>13ws">11mf="+code1 nam2bch.326hre3="liii="line"ptEXPORTMODULE_DESCRIPTIOde=l" class="sreMODULE_DESCRIPTIOd"+codexn#37;dne"n#37;x\n&qu431" B repre claer/declaer"line/a> rhref1136<"+cor="+c"gen"L3in2te=eln" cl2ss=13cod>11mf="+code=GF_T2ref=326hre3="liii


11mf="+footer"> The orig rel LXR softwr t"y gf_"cor="+c"ghttp://sourceL39ge.net/projects/lxr">LXR trefunt">ERNELefuncrexperifnamel vers))c*"y cor="+c"gmailto:lxr@codux.no">lxr@codux.noERNE.
11mf="+subfooter"> lxr.codux.no kindly hosCH1s"y cor="+c"ghttp://www.redpill-codpro.no">Redpill Lodpro ASERNELede yourr greLodux6" idlylinga sssop5s4GF id serviced sirit_1995.