[sheepdog] [PATCH 1/9] add forward error correction for erasure code
Hitoshi Mitake
mitake.hitoshi at gmail.com
Fri Sep 20 11:03:09 CEST 2013
> +
> +static int fec_initialized;
> +static void init_fec(void)
> +{
> + generate_gf();
> + _init_mul_table();
> + fec_initialized = 1;
> +}
> +
> +/*
> + * This section contains the proper FEC encoding/decoding routines.
> + * The encoding matrix is computed starting with a Vandermonde matrix,
> + * and then transforming it into a systematic matrix.
> + */
> +
> +#define FEC_MAGIC 0xFECC0DEC
> +
> +void fec_free(struct fec *p)
> +{
> + assert(p != NULL && p->magic == (((FEC_MAGIC ^ p->k) ^ p->n) ^
> + (unsigned long) (p->enc_matrix)));
> + free(p->enc_matrix);
> + free(p);
> +}
> +
> +struct fec *fec_new(unsigned short k, unsigned short n)
> +{
> + unsigned row, col;
> + uint8_t *p, *tmp_m;
> +
> + struct fec *retval;
> +
> + if (fec_initialized == 0)
> + init_fec();
Let's call init_fec() in main() of sheep and remove fec_initialized.
Thanks,
Hitoshi
More information about the sheepdog
mailing list