PageRenderTime 69ms CodeModel.GetById 20ms app.highlight 46ms RepoModel.GetById 1ms app.codeStats 0ms

/FFdecsa/parallel_064_8char.h

https://bitbucket.org/a84/gs_public/
C++ Header | 274 lines | 230 code | 25 blank | 19 comment | 1 complexity | 576be769cf5a8e1d6ac6777b29b40841 MD5 | raw file
  1/* FFdecsa -- fast decsa algorithm
  2 *
  3 * Copyright (C) 2003-2004  fatih89r
  4 *
  5 * This program is free software; you can redistribute it and/or modify
  6 * it under the terms of the GNU General Public License as published by
  7 * the Free Software Foundation; either version 2 of the License, or
  8 * (at your option) any later version.
  9 *
 10 * This program is distributed in the hope that it will be useful,
 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 * GNU General Public License for more details.
 14 *
 15 * You should have received a copy of the GNU General Public License
 16 * along with this program; if not, write to the Free Software
 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 18 */
 19
 20
 21struct group_t{
 22  unsigned char s1,s2,s3,s4,s5,s6,s7,s8;
 23};
 24typedef struct group_t group;
 25
 26#define GROUP_PARALLELISM 64
 27
 28group static inline FF0(){
 29  group res;
 30  res.s1=0x0;
 31  res.s2=0x0;
 32  res.s3=0x0;
 33  res.s4=0x0;
 34  res.s5=0x0;
 35  res.s6=0x0;
 36  res.s7=0x0;
 37  res.s8=0x0;
 38  return res;
 39}
 40
 41group static inline FF1(){
 42  group res;
 43  res.s1=0xff;
 44  res.s2=0xff;
 45  res.s3=0xff;
 46  res.s4=0xff;
 47  res.s5=0xff;
 48  res.s6=0xff;
 49  res.s7=0xff;
 50  res.s8=0xff;
 51  return res;
 52}
 53
 54group static inline FFAND(group a,group b){
 55  group res;
 56  res.s1=a.s1&b.s1;
 57  res.s2=a.s2&b.s2;
 58  res.s3=a.s3&b.s3;
 59  res.s4=a.s4&b.s4;
 60  res.s5=a.s5&b.s5;
 61  res.s6=a.s6&b.s6;
 62  res.s7=a.s7&b.s7;
 63  res.s8=a.s8&b.s8;
 64  return res;
 65}
 66
 67group static inline FFOR(group a,group b){
 68  group res;
 69  res.s1=a.s1|b.s1;
 70  res.s2=a.s2|b.s2;
 71  res.s3=a.s3|b.s3;
 72  res.s4=a.s4|b.s4;
 73  res.s5=a.s5|b.s5;
 74  res.s6=a.s6|b.s6;
 75  res.s7=a.s7|b.s7;
 76  res.s8=a.s8|b.s8;
 77  return res;
 78}
 79
 80group static inline FFXOR(group a,group b){
 81  group res;
 82  res.s1=a.s1^b.s1;
 83  res.s2=a.s2^b.s2;
 84  res.s3=a.s3^b.s3;
 85  res.s4=a.s4^b.s4;
 86  res.s5=a.s5^b.s5;
 87  res.s6=a.s6^b.s6;
 88  res.s7=a.s7^b.s7;
 89  res.s8=a.s8^b.s8;
 90  return res;
 91}
 92
 93group static inline FFNOT(group a){
 94  group res;
 95  res.s1=~a.s1;
 96  res.s2=~a.s2;
 97  res.s3=~a.s3;
 98  res.s4=~a.s4;
 99  res.s5=~a.s5;
100  res.s6=~a.s6;
101  res.s7=~a.s7;
102  res.s8=~a.s8;
103  return res;
104}
105
106
107/* 64 rows of 64 bits */
108
109void static inline FFTABLEIN(unsigned char *tab, int g, unsigned char *data){
110  *(((int *)tab)+2*g)=*((int *)data);
111  *(((int *)tab)+2*g+1)=*(((int *)data)+1);
112}
113
114void static inline FFTABLEOUT(unsigned char *data, unsigned char *tab, int g){
115  *((int *)data)=*(((int *)tab)+2*g);
116  *(((int *)data)+1)=*(((int *)tab)+2*g+1);
117}
118
119void static inline FFTABLEOUTXORNBY(int n, unsigned char *data, unsigned char *tab, int g){
120  int j;
121  for(j=0;j<n;j++){
122    *(data+j)^=*(tab+8*g+j);
123  }
124}
125
126struct batch_t{
127  unsigned char s1,s2,s3,s4,s5,s6,s7,s8;
128};
129typedef struct batch_t batch;
130
131#define BYTES_PER_BATCH 8
132
133batch static inline B_FFAND(batch a,batch b){
134  batch res;
135  res.s1=a.s1&b.s1;
136  res.s2=a.s2&b.s2;
137  res.s3=a.s3&b.s3;
138  res.s4=a.s4&b.s4;
139  res.s5=a.s5&b.s5;
140  res.s6=a.s6&b.s6;
141  res.s7=a.s7&b.s7;
142  res.s8=a.s8&b.s8;
143  return res;
144}
145
146batch static inline B_FFOR(batch a,batch b){
147  batch res;
148  res.s1=a.s1|b.s1;
149  res.s2=a.s2|b.s2;
150  res.s3=a.s3|b.s3;
151  res.s4=a.s4|b.s4;
152  res.s5=a.s5|b.s5;
153  res.s6=a.s6|b.s6;
154  res.s7=a.s7|b.s7;
155  res.s8=a.s8|b.s8;
156  return res;
157}
158
159batch static inline B_FFXOR(batch a,batch b){
160  batch res;
161  res.s1=a.s1^b.s1;
162  res.s2=a.s2^b.s2;
163  res.s3=a.s3^b.s3;
164  res.s4=a.s4^b.s4;
165  res.s5=a.s5^b.s5;
166  res.s6=a.s6^b.s6;
167  res.s7=a.s7^b.s7;
168  res.s8=a.s8^b.s8;
169  return res;
170}
171
172
173batch static inline B_FFN_ALL_29(){
174  batch res;
175  res.s1=0x29;
176  res.s2=0x29;
177  res.s3=0x29;
178  res.s4=0x29;
179  res.s5=0x29;
180  res.s6=0x29;
181  res.s7=0x29;
182  res.s8=0x29;
183  return res;
184}
185batch static inline B_FFN_ALL_02(){
186  batch res;
187  res.s1=0x02;
188  res.s2=0x02;
189  res.s3=0x02;
190  res.s4=0x02;
191  res.s5=0x02;
192  res.s6=0x02;
193  res.s7=0x02;
194  res.s8=0x02;
195  return res;
196}
197batch static inline B_FFN_ALL_04(){
198  batch res;
199  res.s1=0x04;
200  res.s2=0x04;
201  res.s3=0x04;
202  res.s4=0x04;
203  res.s5=0x04;
204  res.s6=0x04;
205  res.s7=0x04;
206  res.s8=0x04;
207  return res;
208}
209batch static inline B_FFN_ALL_10(){
210  batch res;
211  res.s1=0x10;
212  res.s2=0x10;
213  res.s3=0x10;
214  res.s4=0x10;
215  res.s5=0x10;
216  res.s6=0x10;
217  res.s7=0x10;
218  res.s8=0x10;
219  return res;
220}
221batch static inline B_FFN_ALL_40(){
222  batch res;
223  res.s1=0x40;
224  res.s2=0x40;
225  res.s3=0x40;
226  res.s4=0x40;
227  res.s5=0x40;
228  res.s6=0x40;
229  res.s7=0x40;
230  res.s8=0x40;
231  return res;
232}
233batch static inline B_FFN_ALL_80(){
234  batch res;
235  res.s1=0x80;
236  res.s2=0x80;
237  res.s3=0x80;
238  res.s4=0x80;
239  res.s5=0x80;
240  res.s6=0x80;
241  res.s7=0x80;
242  res.s8=0x80;
243  return res;
244}
245
246batch static inline B_FFSH8L(batch a,int n){
247  batch res;
248  res.s1=a.s1<<n;
249  res.s2=a.s2<<n;
250  res.s3=a.s3<<n;
251  res.s4=a.s4<<n;
252  res.s5=a.s5<<n;
253  res.s6=a.s6<<n;
254  res.s7=a.s7<<n;
255  res.s8=a.s8<<n;
256  return res;
257}
258
259batch static inline B_FFSH8R(batch a,int n){
260  batch res;
261  res.s1=a.s1>>n;
262  res.s2=a.s2>>n;
263  res.s3=a.s3>>n;
264  res.s4=a.s4>>n;
265  res.s5=a.s5>>n;
266  res.s6=a.s6>>n;
267  res.s7=a.s7>>n;
268  res.s8=a.s8>>n;
269  return res;
270}
271
272
273void static inline M_EMPTY(void){
274}