Jerasure  1.2
A Library in C/C++ Facilitating Erasure Coding for Storage Applications
galois.h
Go to the documentation of this file.
00001 /* Galois.h
00002  * James S. Plank
00003 
00004 Jerasure - A C/C++ Library for a Variety of Reed-Solomon and RAID-6 Erasure Coding Techniques
00005 
00006 Revision 1.2A
00007 May 24, 2011
00008 
00009 James S. Plank
00010 Department of Electrical Engineering and Computer Science
00011 University of Tennessee
00012 Knoxville, TN 37996
00013 plank@cs.utk.edu
00014 
00015 Copyright (c) 2011, James S. Plank
00016 All rights reserved.
00017 
00018 Redistribution and use in source and binary forms, with or without
00019 modification, are permitted provided that the following conditions
00020 are met:
00021 
00022  - Redistributions of source code must retain the above copyright
00023    notice, this list of conditions and the following disclaimer.
00024 
00025  - Redistributions in binary form must reproduce the above copyright
00026    notice, this list of conditions and the following disclaimer in
00027    the documentation and/or other materials provided with the
00028    distribution.
00029 
00030  - Neither the name of the University of Tennessee nor the names of its
00031    contributors may be used to endorse or promote products derived
00032    from this software without specific prior written permission.
00033 
00034 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00035 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00036 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00037 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00038 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00039 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00040 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00041 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00042 AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00043 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
00044 WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00045 POSSIBILITY OF SUCH DAMAGE.
00046 
00047  */
00048 
00049 #ifndef _GALOIS_H
00050 #define _GALOIS_H
00051 
00052 #include <stdio.h>
00053 #include <stdlib.h>
00054 
00055 extern int galois_single_multiply(int a, int b, int w);
00056 extern int galois_single_divide(int a, int b, int w);
00057 extern int galois_log(int value, int w);
00058 extern int galois_ilog(int value, int w);
00059 
00060 extern int galois_create_log_tables(int w);   /* Returns 0 on success, -1 on failure */
00061 extern int galois_logtable_multiply(int x, int y, int w);
00062 extern int galois_logtable_divide(int x, int y, int w);
00063 
00064 extern int galois_create_mult_tables(int w);   /* Returns 0 on success, -1 on failure */
00065 extern int galois_multtable_multiply(int x, int y, int w);
00066 extern int galois_multtable_divide(int x, int y, int w);
00067 
00068 extern int galois_shift_multiply(int x, int y, int w);
00069 extern int galois_shift_divide(int x, int y, int w);
00070 
00071 extern int galois_create_split_w8_tables();
00072 extern int galois_split_w8_multiply(int x, int y);
00073 
00074 extern int galois_inverse(int x, int w);
00075 extern int galois_shift_inverse(int y, int w);
00076 
00077 extern int *galois_get_mult_table(int w);
00078 extern int *galois_get_div_table(int w);
00079 extern int *galois_get_log_table(int w);
00080 extern int *galois_get_ilog_table(int w);
00081 
00082 void galois_region_xor(           char *r1,         /* Region 1 */
00083                                   char *r2,         /* Region 2 */
00084                                   char *r3,         /* Sum region (r3 = r1 ^ r2) -- can be r1 or r2 */
00085                                   int nbytes);      /* Number of bytes in region */
00086 
00087 /* These multiply regions in w=8, w=16 and w=32.  They are much faster
00088    than calling galois_single_multiply.  The regions must be long word aligned. */
00089 
00090 void galois_w08_region_multiply(char *region,       /* Region to multiply */
00091                                   int multby,       /* Number to multiply by */
00092                                   int nbytes,       /* Number of bytes in region */
00093                                   char *r2,         /* If r2 != NULL, products go here.  
00094                                                        Otherwise region is overwritten */
00095                                   int add);         /* If (r2 != NULL && add) the produce is XOR'd with r2 */
00096 
00097 void galois_w16_region_multiply(char *region,       /* Region to multiply */
00098                                   int multby,       /* Number to multiply by */
00099                                   int nbytes,       /* Number of bytes in region */
00100                                   char *r2,         /* If r2 != NULL, products go here.  
00101                                                        Otherwise region is overwritten */
00102                                   int add);         /* If (r2 != NULL && add) the produce is XOR'd with r2 */
00103 
00104 void galois_w32_region_multiply(char *region,       /* Region to multiply */
00105                                   int multby,       /* Number to multiply by */
00106                                   int nbytes,       /* Number of bytes in region */
00107                                   char *r2,         /* If r2 != NULL, products go here.  
00108                                                        Otherwise region is overwritten */
00109                                   int add);         /* If (r2 != NULL && add) the produce is XOR'd with r2 */
00110 
00111 #endif
 All Files Functions Variables Defines