mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 15:53:28 +03:00
Fixes #71 - some crazy races inside erasure and simplify the code
- This change also brings in changing 'unsigned char' to 'uint8_t' for brevity
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
Copyright(c) 2011-2014 Intel Corporation All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
// Global GF(256) tables
|
||||
#ifndef GF_LARGE_TABLES
|
||||
unsigned char gff_base[] = {
|
||||
uint8_t gff_base[] = {
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a,
|
||||
0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, 0x4c, 0x98, 0x2d, 0x5a,
|
||||
0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30,
|
||||
@@ -61,7 +61,7 @@ unsigned char gff_base[] = {
|
||||
0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x01
|
||||
};
|
||||
|
||||
unsigned char gflog_base[] = {
|
||||
uint8_t gflog_base[] = {
|
||||
0x00, 0xff, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf,
|
||||
0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, 0x04, 0x64, 0xe0, 0x0e,
|
||||
0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08,
|
||||
@@ -90,7 +90,7 @@ unsigned char gflog_base[] = {
|
||||
0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf
|
||||
};
|
||||
#else
|
||||
unsigned char gf_mul_table_base[] = {
|
||||
uint8_t gf_mul_table_base[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -6647,7 +6647,7 @@ unsigned char gf_mul_table_base[] = {
|
||||
0xc6, 0x39, 0xfe, 0x01, 0x1d, 0xe2
|
||||
};
|
||||
|
||||
unsigned char gf_inv_table_base[] = {
|
||||
uint8_t gf_inv_table_base[] = {
|
||||
0x00, 0x01, 0x8e, 0xf4, 0x47, 0xa7, 0x7a, 0xba, 0xad, 0x9d,
|
||||
0xdd, 0x98, 0x3d, 0xaa, 0x5d, 0x96, 0xd8, 0x72, 0xc0, 0x58,
|
||||
0xe0, 0x3e, 0x4c, 0x66, 0x90, 0xde, 0x55, 0x80, 0xa0, 0x83,
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#ifndef _ERASURE_CODE_H_
|
||||
#define _ERASURE_CODE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
/**
|
||||
* @file erasure_code.h
|
||||
* @brief Interface to functions supporting erasure code encode and decode.
|
||||
@@ -71,7 +72,7 @@ extern "C" {
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void ec_init_tables(int k, int rows, unsigned char* a, unsigned char* gftbls);
|
||||
void ec_init_tables(int k, int rows, uint8_t* a, uint8_t* gftbls);
|
||||
|
||||
/**
|
||||
* @brief Generate or decode erasure codes on blocks of data.
|
||||
@@ -93,7 +94,7 @@ void ec_init_tables(int k, int rows, unsigned char* a, unsigned char* gftbls);
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void ec_encode_data_sse(int len, int k, int rows, unsigned char *gftbls, unsigned char **data, unsigned char **coding);
|
||||
void ec_encode_data_sse(int len, int k, int rows, uint8_t *gftbls, uint8_t **data, uint8_t **coding);
|
||||
|
||||
|
||||
/**
|
||||
@@ -118,7 +119,7 @@ void ec_encode_data_sse(int len, int k, int rows, unsigned char *gftbls, unsigne
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void ec_encode_data(int len, int k, int rows, unsigned char *gftbls, unsigned char **data, unsigned char **coding);
|
||||
void ec_encode_data(int len, int k, int rows, uint8_t *gftbls, uint8_t **data, uint8_t **coding);
|
||||
|
||||
|
||||
/**
|
||||
@@ -140,7 +141,7 @@ void ec_encode_data(int len, int k, int rows, unsigned char *gftbls, unsigned ch
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void ec_encode_data_base(int len, int srcs, int dests, unsigned char *v, unsigned char **src, unsigned char **dest);
|
||||
void ec_encode_data_base(int len, int srcs, int dests, uint8_t *v, uint8_t **src, uint8_t **dest);
|
||||
|
||||
|
||||
/**
|
||||
@@ -161,8 +162,8 @@ void ec_encode_data_base(int len, int srcs, int dests, unsigned char *v, unsigne
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void gf_vect_dot_prod_sse(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t *dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product.
|
||||
@@ -182,8 +183,8 @@ void gf_vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void gf_vect_dot_prod_avx(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t *dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product.
|
||||
@@ -203,8 +204,8 @@ void gf_vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void gf_vect_dot_prod_avx2(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t *dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with two outputs.
|
||||
@@ -225,8 +226,8 @@ void gf_vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_2vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_2vect_dot_prod_sse(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with two outputs.
|
||||
@@ -247,8 +248,8 @@ void gf_2vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_2vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_2vect_dot_prod_avx(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with two outputs.
|
||||
@@ -269,8 +270,8 @@ void gf_2vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_2vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_2vect_dot_prod_avx2(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with three outputs.
|
||||
@@ -291,8 +292,8 @@ void gf_2vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_3vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_3vect_dot_prod_sse(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with three outputs.
|
||||
@@ -313,8 +314,8 @@ void gf_3vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_3vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_3vect_dot_prod_avx(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with three outputs.
|
||||
@@ -335,8 +336,8 @@ void gf_3vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_3vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_3vect_dot_prod_avx2(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with four outputs.
|
||||
@@ -357,8 +358,8 @@ void gf_3vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_4vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_4vect_dot_prod_sse(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with four outputs.
|
||||
@@ -379,8 +380,8 @@ void gf_4vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_4vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_4vect_dot_prod_avx(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with four outputs.
|
||||
@@ -401,8 +402,8 @@ void gf_4vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_4vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_4vect_dot_prod_avx2(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with five outputs.
|
||||
@@ -423,8 +424,8 @@ void gf_4vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_5vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_5vect_dot_prod_sse(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with five outputs.
|
||||
@@ -445,8 +446,8 @@ void gf_5vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_5vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_5vect_dot_prod_avx(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with five outputs.
|
||||
@@ -467,8 +468,8 @@ void gf_5vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_5vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_5vect_dot_prod_avx2(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with six outputs.
|
||||
@@ -489,8 +490,8 @@ void gf_5vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_6vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_6vect_dot_prod_sse(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with six outputs.
|
||||
@@ -511,8 +512,8 @@ void gf_6vect_dot_prod_sse(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_6vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_6vect_dot_prod_avx(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product with six outputs.
|
||||
@@ -533,8 +534,8 @@ void gf_6vect_dot_prod_avx(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_6vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char **dest);
|
||||
void gf_6vect_dot_prod_avx2(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t **dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product, runs baseline version.
|
||||
@@ -556,8 +557,8 @@ void gf_6vect_dot_prod_avx2(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_dot_prod_base(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void gf_vect_dot_prod_base(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t *dest);
|
||||
|
||||
/**
|
||||
* @brief GF(2^8) vector dot product, runs appropriate version.
|
||||
@@ -579,8 +580,8 @@ void gf_vect_dot_prod_base(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_vect_dot_prod(int len, int vlen, unsigned char *gftbls,
|
||||
unsigned char **src, unsigned char *dest);
|
||||
void gf_vect_dot_prod(int len, int vlen, uint8_t *gftbls,
|
||||
uint8_t **src, uint8_t *dest);
|
||||
|
||||
/**********************************************************************
|
||||
* The remaining are lib support functions used in GF(2^8) operations.
|
||||
@@ -594,7 +595,7 @@ void gf_vect_dot_prod(int len, int vlen, unsigned char *gftbls,
|
||||
* @returns Product of a and b in GF(2^8)
|
||||
*/
|
||||
|
||||
unsigned char gf_mul(unsigned char a, unsigned char b);
|
||||
uint8_t gf_mul(uint8_t a, uint8_t b);
|
||||
|
||||
/**
|
||||
* @brief Single element GF(2^8) inverse.
|
||||
@@ -603,7 +604,7 @@ unsigned char gf_mul(unsigned char a, unsigned char b);
|
||||
* @returns Field element b such that a x b = {1}
|
||||
*/
|
||||
|
||||
unsigned char gf_inv(unsigned char a);
|
||||
uint8_t gf_inv(uint8_t a);
|
||||
|
||||
/**
|
||||
* @brief Generate a matrix of coefficients to be used for encoding.
|
||||
@@ -622,7 +623,7 @@ unsigned char gf_inv(unsigned char a);
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_gen_rs_matrix(unsigned char *a, int m, int k);
|
||||
void gf_gen_rs_matrix(uint8_t *a, int m, int k);
|
||||
|
||||
/**
|
||||
* @brief Generate a Cauchy matrix of coefficients to be used for encoding.
|
||||
@@ -637,7 +638,7 @@ void gf_gen_rs_matrix(unsigned char *a, int m, int k);
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void gf_gen_cauchy1_matrix(unsigned char *a, int m, int k);
|
||||
void gf_gen_cauchy1_matrix(uint8_t *a, int m, int k);
|
||||
|
||||
/**
|
||||
* @brief Invert a matrix in GF(2^8)
|
||||
@@ -648,7 +649,7 @@ void gf_gen_cauchy1_matrix(unsigned char *a, int m, int k);
|
||||
* @returns 0 successful, other fail on singular input matrix
|
||||
*/
|
||||
|
||||
int gf_invert_matrix(unsigned char *in, unsigned char *out, const int n);
|
||||
int gf_invert_matrix(uint8_t *in, uint8_t *out, const int n);
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ extern "C" {
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int gf_vect_mul_sse(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
int gf_vect_mul_sse(int len, uint8_t *gftbl, void *src, void *dest);
|
||||
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ int gf_vect_mul_sse(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int gf_vect_mul_avx(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
int gf_vect_mul_avx(int len, uint8_t *gftbl, void *src, void *dest);
|
||||
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ int gf_vect_mul_avx(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
* @returns 0 pass, other fail
|
||||
*/
|
||||
|
||||
int gf_vect_mul(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
int gf_vect_mul(int len, uint8_t *gftbl, void *src, void *dest);
|
||||
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ int gf_vect_mul(int len, unsigned char *gftbl, void *src, void *dest);
|
||||
* @param gftbl Table output.
|
||||
*/
|
||||
|
||||
void gf_vect_mul_init(unsigned char c, unsigned char* gftbl);
|
||||
void gf_vect_mul_init(uint8_t c, uint8_t* gftbl);
|
||||
|
||||
|
||||
/**
|
||||
@@ -138,8 +138,8 @@ void gf_vect_mul_init(unsigned char c, unsigned char* gftbl);
|
||||
* @param dest Pointer to destination data array. Must be aligned to 32B.
|
||||
*/
|
||||
|
||||
void gf_vect_mul_base(int len, unsigned char *a, unsigned char *src,
|
||||
unsigned char *dest);
|
||||
void gf_vect_mul_base(int len, uint8_t *a, uint8_t *src,
|
||||
uint8_t *dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user