Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /branches/mty-makai/mty.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 206 - (hide annotations) (download) (as text)
Sat Aug 16 13:11:14 2008 UTC (15 years, 7 months ago) by notanpe
File MIME type: text/x-csrc
File size: 48792 byte(s)
GetProcessAffinityMask()の返り値チェックのミスを修正。
1 chapuni 1 /***********************************************************************
2     *
3 chapuni 26 * file: mty.c
4 chapuni 1 *
5 chapuni 2 * ‚Ü‚ A‘Ň‚Ä‰ŽB
6 chapuni 1 *
7     * $Id$
8     *
9     */
10    
11     #include <assert.h>
12     #include <ctype.h>
13 chapuni 24 #include <errno.h>
14 chapuni 9 #include <limits.h>
15 chapuni 24 #include <stdarg.h>
16 chapuni 20 #include <stddef.h>
17 chapuni 1 #include <stdio.h>
18     #include <stdlib.h>
19     #include <string.h>
20     #include <time.h>
21 notanpe 192 #include <sys/timeb.h>
22 notanpe 148 #include <sys/types.h>
23 chapuni 10
24 notanpe 197 /* MAKAI start */
25     #include <unistd.h>
26     #include <libgen.h>
27 notanpe 203 #include <limits.h>
28 notanpe 197 /* MAKAI end */
29    
30 chapuni 10 #if defined(WIN32)
31    
32     #include <windows.h>
33 notanpe 148 #include <process.h>
34 chapuni 10
35     #elif defined(__GNUC__)
36    
37     #include <sys/time.h>
38    
39     #endif
40    
41 chapuni 26 #include "config.h"
42 chapuni 39 #include "cp932.h"
43 chapuni 1 #include "crypt64.h"
44 chapuni 41 #include "desconst.h"
45 chapuni 46 #include "expr_parse.h"
46     #include "scoreboard.h"
47     #include "synth.h"
48 chapuni 74 #include "tr64.h"
49 chapuni 26 #include "translate.h"
50 notanpe 148 #include "util.h"
51 chapuni 99 #include "wdict.h"
52 chapuni 1
53 chapuni 39 #if USE_DT
54     #include "dt4.h"
55     #endif
56    
57 notanpe 197 /* MAKAI start */
58 notanpe 198 #define TRIP_LEN 10
59    
60 notanpe 197 #define MIN_THREAD 1
61     #define MAX_THREAD 32
62     int nThread = 0;
63 notanpe 199 uint64_t pmask = 0;
64 notanpe 197
65     #define MIN_UME 3
66     #define MAX_UME 6
67     unsigned char umeStr[10];
68     int umeLen;
69 notanpe 198
70 notanpe 204 FILE *nfp; /* ‘S” */
71     FILE *tfp; /* ŞˆČŠO‚Ě“ÁŽęŒŸő */
72 notanpe 203
73     unsigned int seed;
74     int verbose;
75 notanpe 197 /* MAKAI end */
76    
77 notanpe 192 /* CRYPT64 ‹LqŽq */
78     static
79     struct CRYPT64_DESC const *const crypt64_descs[] =
80     {
81     &crypt64_desc,
82     };
83    
84 chapuni 1 /* ŒŽƒNƒ‰ƒX */
85 chapuni 41 static
86 chapuni 1 struct
87     {
88 notanpe 148 unsigned short map[256];
89 chapuni 1 } kcls[8 + 8];
90    
91 chapuni 26 /* Šg’ŁŒŽƒNƒ‰ƒX */
92 chapuni 1 #define KCLS_DT0 64
93     #define KCLS_DT1 128
94     #define KCLS_K2 256
95    
96     #if USE_DT
97     /* ŒŽƒLƒ—pŽŤ‘ƒCƒ“ƒfƒNƒX */
98     struct DT *kd[8 + 8];
99    
100     /* ŽŤ‘ƒCƒ“ƒfƒNƒX */
101     struct DT *dtidx[0x100 + 1];
102     #endif
103    
104 notanpe 198 /* MAKAI start */
105     int special = 0;
106 notanpe 205 #define ST_ALLN 1 /* ‘S” */
107     #define ST_NIKO 1<<1 /* “ń\ */
108     #define ST_BUOO 1<<8 /* ‚Ô‚¨ */
109     #define ST_DOSU 1<<9 /* “{” */
110 notanpe 198
111     void
112     comment( str )
113     char *str;
114     {
115     if ( strlen( str ) >= 4 ) {
116     if ( str[1] == '[' && str[3] == ']' ) {
117     switch ( str[2] ) {
118 notanpe 203 case '0': special |= ST_ALLN; break;
119     case '1': special |= ST_NIKO; break;
120     case '8': special |= ST_BUOO; break;
121 notanpe 204 case '9': special |= (ST_DOSU | ST_ALLN); break;
122 notanpe 198 }
123     }
124     }
125     }
126     /* MAKAI end */
127    
128 chapuni 1 /* Žw’肳‚ę‚˝ƒNƒ‰ƒX‚Ć“ü‚Á‚Ä‚˘‚éƒL[‚Š‚çAclassify ‚đs‚¤ */
129     void
130 notanpe 148 key_make_map(uint8_t *key, int n)
131 chapuni 1 {
132     int i, j;
133     unsigned c = kcls[n].map[key[n]];
134    
135 chapuni 39 #if USE_DT
136 chapuni 1 if (3 <= n && n < 7 && kd[n - 3])
137     {
138     /* ŽŤ‘‚ĚƒPƒc‚Ě•śŽšBŒă‚ë‚Ƀiƒjƒ„ƒ‰ƒLƒƒƒ‰ƒNƒ^‚Ş—ˆ‚é */
139     c = kd[n - 3]->c[0];
140     if ((0x81 <= c && c <= 0x9F)
141     || (0xE0 <= c && c <= 0xFC))
142     c = KCLS_K2;
143     else
144     c = (cp932[256 * key[n]]
145     | cp932[256 * (key[n] ^ 0x80)]);
146     #if DEBUG>=1
147     printf("*n=%d, key=%02X, cls=%04X\n",
148     n,
149     key[n],
150     c);
151     #endif
152     }
153     else if (2 <= n && n < 6 && kd[n - 2])
154     {
155     return;
156     }
157     else if (1 <= n && n < 5 && kd[n - 1])
158     {
159     return;
160     }
161     else if (1 <= n && n < 5 && !kd[n - 1]
162     //&& (c & KCLS_K2)
163     && (c & KCLS_DT1))
164     {
165     /* ŠżŽš2•śŽš‚đE‚Á‚Ä‚˘‚Ť‚܂ */
166     #if DEBUG>=1
167     printf("(%d)%02X %02X(%02X:%02X:%02X:%02X)\n",
168     n, key[n - 1], key[n],
169     cp932[(256 * key[n - 1] + key[n])],
170     cp932[(256 * key[n - 1] + key[n]) ^ 0x0080],
171     cp932[(256 * key[n - 1] + key[n]) ^ 0x8000],
172     cp932[(256 * key[n - 1] + key[n]) ^ 0x8080]);
173     #endif
174     if (n != 1 && n != 2
175     && (cp932[(256 * key[n - 1] + key[n]) ^ 0x0080] & KCLS_DT1))
176     key[n] ^= 0x80;
177     else if (n != 2 && n != 3
178     && (cp932[(256 * key[n - 1] + key[n]) ^ 0x8000] & KCLS_DT1))
179     key[n - 1] ^= 0x80;
180     else if (n > 3 && (cp932[(256 * key[n - 1] + key[n]) ^ 0x8080] & KCLS_DT1))
181     key[n - 1] ^= 0x80, key[n] ^= 0x80;
182     if (cp932[256 * key[n - 1] + key[n]] & KCLS_DT1)
183     {
184     for (kd[n - 1] = dtidx[key[n - 1]];
185     kd[n - 1]->c[1] != key[n];
186     kd[n - 1]++)
187     assert(kd[n - 1]->c[0] == key[n - 1]);
188     #if DEBUG>=1
189     printf("(%02X%02X:%02X%02X)%c%c%c%c\n",
190     kd[n - 1]->c[0],
191     kd[n - 1]->c[1],
192     kd[n - 1]->c[2],
193     kd[n - 1]->c[3],
194     kd[n - 1]->c[0],
195     kd[n - 1]->c[1],
196     kd[n - 1]->c[2],
197     kd[n - 1]->c[3]);
198     #endif
199     return;
200     }
201     }
202     else if (n < 4 && (c & KCLS_DT0) && kd[n] == NULL)
203     {
204     /* ƒJƒ^ƒJƒi–„‚ߍž‚Ý‚˘‚Ť‚Ü‚ˇ */
205     assert(kd[n] == NULL);
206     #if DEBUG>=1
207     printf("n=%d, key=%02X\n", n, key[n]);
208     #endif
209     kd[n] = dtidx[key[n]];
210     if (!kd[n]
211     && !(n == 1 || n == 2)
212     && dtidx[key[n] ^ 0x80])
213     {
214     key[n] ^= 0x80;
215     kd[n] = dtidx[key[n]];
216     }
217     if (kd[n])
218     return;
219     }
220     else
221     {
222     kd[n] = NULL;
223     }
224 chapuni 39 #endif
225 chapuni 1
226     /* ĹŒă‚Ě•”•Ş‚Í class map ‚đśŹ‚ˇ‚é•K—vƒiƒV */
227     if (n >= 6)
228     return;
229    
230     for (i = 0; i < 256; i++)
231     {
232 chapuni 25 unsigned bm = 0;
233 chapuni 1 #if 1
234     if (c & KCLS_K1)
235     {
236     if (cp932[256 * key[n] + i] & KCLS_K1)
237     bm |= KCLS_K2 | (cp932[256 * key[n] + i] & KCLS_DT1);
238     if (cp932[256 * (key[n] ^ 0x80) + i] & KCLS_K1)
239     bm |= KCLS_K2 | (cp932[256 * (key[n] ^ 0x80) + i] & KCLS_DT1);
240     #if 0
241     bm |= ((cp932[256 * key[n] + i] & KCLS_K1)
242     || (cp932[256 * (key[n] ^ 0x80) + i] & KCLS_K1)
243     ? KCLS_K2 : 0);
244     #endif
245     }
246     if (c & (KCLS_AN | KCLS_KA | KCLS_K2))
247     for (j = 0; j < 256; j++)
248     {
249     bm |= cp932[256 * i + j] & (KCLS_AN | KCLS_KA | KCLS_K1
250     | KCLS_DT0);
251     #if 0
252     if (j >= 127 && !(n == 0 || n == 1))
253     break;
254     #endif
255     }
256     kcls[n + 1].map[i] = bm;
257     #endif
258     if (i >= 128 && !(n == 0 || n == 1))
259     kcls[n + 1].map[i - 128] |= kcls[n + 1].map[i];
260     }
261    
262     if (n < 6)
263     kcls[n + 1].map[0x00] = kcls[n + 1].map[0x80] = 0;
264     if (n == 6)
265     kcls[7].map[0x00] |= KCLS_AN;
266     }
267    
268 chapuni 39 #if USE_DT
269 chapuni 1 unsigned
270     dt_get(int kdn,
271     int xn,
272     int n,
273     int ch)
274     {
275     int i;
276     #if DEBUG>=1
277     printf("*dt_get(%d)%c%c%c%c(%02X%02X:%02X%02X)->ch=%d",
278     n,
279     kd[kdn]->c[0], kd[kdn]->c[1], kd[kdn]->c[2], kd[kdn]->c[3],
280     kd[kdn]->c[0], kd[kdn]->c[1], kd[kdn]->c[2], kd[kdn]->c[3],
281     ch);
282     #endif
283     /* ‚Ü‚¸‚͐”‚Ś‚é */
284     for (i = 0;
285     kd[kdn][i].c[xn] == kd[kdn]->c[xn];
286     i++)
287     ;
288     assert(i > 0);
289     kd[kdn] += ch % i;
290     #if DEBUG>=1
291     printf("/%d\n dt_get: %c%c%c%c(%02X%02X:%02X%02X)->ch=%d\n",
292     i,
293     kd[kdn]->c[0], kd[kdn]->c[1], kd[kdn]->c[2], kd[kdn]->c[3],
294     kd[kdn]->c[0], kd[kdn]->c[1], kd[kdn]->c[2], kd[kdn]->c[3],
295     ch);
296     #endif
297     return kd[kdn]->c[n];
298     }
299 chapuni 39 #endif
300 chapuni 1
301     /* ƒ}ƒbƒv‚Š‚ç•śŽš‚đE‚Á‚ăZƒbƒg */
302     unsigned
303     key_set(int n, unsigned ch)
304     {
305     int cnt = 0, i;
306    
307 chapuni 39 #if USE_DT
308 chapuni 1 if (3 <= n && n < 7 && kd[n - 3])
309     {
310     return dt_get(n - 3, 2, 3, ch);
311     return kd[n - 3]->c[3];
312     }
313     else if (2 <= n && n < 6 && kd[n - 2])
314     {
315     return dt_get(n - 2, 1, 2, ch);
316     return kd[n - 2]->c[2];
317     }
318     else if (1 <= n && n < 5 && kd[n - 1])
319     {
320     return dt_get(n - 1, 0, 1, ch);
321     return kd[n - 1]->c[1];
322     }
323 chapuni 39 #endif
324 chapuni 1
325     #if DEBUG>=3
326     if (cnt == 0)
327     {
328     printf("n=%d, ch=%d, (n-1)=%02X\n", n, ch, key[n - 1]);
329     int j;
330     for (i = 0; i < 16; i++)
331     {
332     printf("map[0x%02X] =", 16 * i);
333     for (j = 0; j < 16; j++)
334     printf(" %03X", kcls[n].map[16 * i + j]);
335     printf("\n");
336     }
337     }
338     #endif
339     for (i = 0; i < 256; i++)
340     {
341     if (kcls[n].map[i])
342     {
343     if (ch-- == 0)
344     return i;
345     cnt++;
346     }
347     if (n != 1 && n != 2 && i >= 127)
348     break;
349     }
350     /* ŒŠ‚Â‚Š‚ç‚ȂЂÁ‚˝‚Ě‚Ĺ‚ŕ‚˘‚Á‚Ř‚ń */
351     assert(cnt > 0);
352     ch %= cnt;
353     for (i = 0; i < 256; i++)
354     if (kcls[n].map[i])
355     {
356     if (ch-- == 0)
357     return i;
358     }
359     assert(!"not matched");
360     return 0;
361     }
362    
363     /* bitwise key ‚đƒZƒbƒg */
364     static
365     void
366     key_set64(struct KEY *key64,
367     int n,
368     unsigned k,
369     unsigned vk,
370     unsigned sk)
371     {
372 chapuni 6 int i, j;
373 chapuni 1 if (!((vk | sk) & 0x7F))
374     return;
375    
376     for (i = 0; i < 7; i++)
377     {
378 chapuni 6 if (n == 7 && i < N_STRIDE) continue;
379 chapuni 1 if (sk & (1 << i))
380     {
381     /* ƒZƒbƒg */
382     int o = tr_pc1[n][6 - i] - 1;
383     if (o < 28)
384     {
385     assert(o >= 0);
386 chapuni 6 for (j = 0; j < N_ALU; j++)
387     key64->k[0][0][o].a[j]
388     = key64->k[0][1][o].a[j]
389     = -!!(k & (1 << i));
390 chapuni 1 }
391     else
392     {
393     assert(o >= 28);
394     assert(o < 56);
395 chapuni 6 for (j = 0; j < N_ALU; j++)
396     key64->k[1][0][o - 28].a[j]
397     = key64->k[1][1][o - 28].a[j]
398     = -!!(k & (1 << i));
399 chapuni 1 }
400     }
401     else if (vk & (1 << i))
402     {
403     /* ”˝“] */
404     int o = tr_pc1[n][6 - i] - 1;
405     if (o < 28)
406     {
407     assert(o >= 0);
408 chapuni 10 for (j = 0; j < N_ALU; j++)
409     key64->k[0][0][o].a[j]
410     = key64->k[0][1][o].a[j]
411     = ~key64->k[0][0][o].a[j];
412 chapuni 1 }
413     else
414     {
415     assert(o >= 28);
416     assert(o < 56);
417 chapuni 10 for (j = 0; j < N_ALU; j++)
418     key64->k[1][0][o - 28].a[j]
419     = key64->k[1][1][o - 28].a[j]
420     = ~key64->k[1][0][o - 28].a[j];
421 chapuni 1 }
422     }
423     }
424     }
425    
426     /* Žw’肳‚ę‚˝ƒNƒ‰ƒX‚ĚŠJŽn’l‚ÉƒŠƒZƒbƒg
427     ’ź‘O‚Ě•śŽš‚ĚƒNƒ‰ƒX‚É”›‚ç‚ę‚é */
428     int
429 notanpe 148 key_reset(uint8_t *key, int n)
430 chapuni 1 {
431 notanpe 197 /* MAKAI start */
432     static char firstCall = 1;
433    
434     if ( firstCall ) {
435     firstCall = 0;
436     } else {
437     if ( umeStr[0] != '\0' && n == 0 ) {
438     exit( 0 );
439     }
440     }
441     /* MAKAI end */
442    
443 chapuni 1 if (n >= 8)
444     return 1;
445     if (n == 7)
446     {
447     key[7] = 0;
448     return 1;
449     }
450    
451 notanpe 197 /* MAKAI start */
452     if (n >= umeLen)
453 chapuni 1 key[n] = key_set(n, 0);
454 notanpe 197 else {
455     if ( umeStr[0] == '\0' ) {
456     key[n] = key_set(n, rand());
457     } else {
458     key[n] = umeStr[n];
459     }
460     }
461     /* MAKAI end */
462 chapuni 1
463     #if DEBUG>=3
464     printf("key[%d]=%02X ncls=%04X\n", n, key[n], kcls[n].map[key[n]]);
465     #endif
466    
467     /* ƒZƒbƒg‚ł‚ę‚˝•śŽš‚đŒł‚ÉAŽŸƒLƒƒƒ‰‚Ě•śŽšƒNƒ‰ƒX‚đŒˆ‚ß‚é */
468 notanpe 148 key_make_map(key, n);
469 chapuni 1
470 notanpe 148 return key_reset(key, n + 1);
471 chapuni 1 }
472    
473     /* Žw’肳‚ę‚˝ŒŽ‹óŠÔ‚Ě’†‚ŁAƒL[‚đ‚ЂƂi‚ß‚é
474     ˆŔ‘S‚ɃCƒ“ƒNƒŠƒƒ“ƒg‚Ĺ‚Ť‚˝ę‡ true ‚đ•Ô‚ˇ */
475     static
476     int
477 notanpe 148 key_inc(uint8_t *key, int n)
478 chapuni 1 {
479     if (n >= 8)
480     return 0;
481     else if (n == 7)
482     {
483 chapuni 6 /* ĹŒă‚ĚƒoƒCƒg */
484 notanpe 148 uint8_t o_k = (key[7] + (1 << N_STRIDE)) & 0x7F;
485     if (!o_k)
486     return 0; /* ƒCƒ“ƒNƒŠƒƒ“ƒg‚Ĺ‚Ť‚ȂЂÁ‚˝‚Ć‚Ť‚ÍŽŸ‚֐i‚ß‚¸‘҂ */
487    
488     /* i‚ß‚é */
489     key[7] = o_k;
490     return 1;
491 chapuni 1 }
492 notanpe 148 else if (key_inc(key, n + 1)
493 chapuni 1 /*
494     && key_inc(n + 1)
495     && key_inc(n + 1)
496     && key_inc(n + 1)*/
497     )
498     return 1;
499    
500     /* Salt ‚̓Cƒ“ƒNƒŠƒƒ“ƒg‚ľ‚Č‚˘–ń‘Ђɂˇ‚é */
501     if (n == 1 || n == 2)
502     return 1;
503    
504     #if DEBUG>=3
505     printf("key_inc(n=%d,ck=%02X)\n", n, key[n]);
506     #endif
507    
508 chapuni 39 #if USE_DT
509 chapuni 1 /* ŽŤ‘Œę‚̓Cƒ“ƒNƒŠƒƒ“ƒg‚ľ‚Ä‚˘‚˘–ń‘Ђɂˇ‚é */
510     if (3 <= n && n < 7 && kd[n - 3])
511     {
512     if ((key[n - 3] & 0x7F) == ((kd[n - 3] + 1)->c[0] & 0x7F)
513     && (key[n - 2] & 0x7F) == ((kd[n - 3] + 1)->c[1] & 0x7F)
514     && (key[n - 1] & 0x7F) == ((kd[n - 3] + 1)->c[2] & 0x7F))
515     {
516     memcpy(&key[n - 3], &(++kd[n - 3])->c[0], 4);
517     #if DEBUG>=2
518     printf(">dt_get:%c%c%c%c(%02X%02X:%02X%02X)\n",
519     kd[n - 3]->c[0], kd[n - 3]->c[1], kd[n - 3]->c[2], kd[n - 3]->c[3],
520     kd[n - 3]->c[0], kd[n - 3]->c[1], kd[n - 3]->c[2], kd[n - 3]->c[3]);
521     #endif
522     return 1;
523     }
524     else
525     {
526     return 0;
527     }
528     }
529     else if (2 <= n && n < 6 && kd[n - 2])
530     {
531     if ((key[n - 2] & 0x7F) == ((kd[n - 2] + 1)->c[0] & 0x7F)
532     && (key[n - 1] & 0x7F) == ((kd[n - 2] + 1)->c[1] & 0x7F))
533     {
534     memcpy(&key[n - 2], &(++kd[n - 2])->c[0], 4);
535     #if DEBUG>=2
536     printf(">dt_get:%c%c%c%c(%02X%02X:%02X%02X)\n",
537     kd[n - 2]->c[0], kd[n - 2]->c[1], kd[n - 2]->c[2], kd[n - 2]->c[3],
538     kd[n - 2]->c[0], kd[n - 2]->c[1], kd[n - 2]->c[2], kd[n - 2]->c[3]);
539     #endif
540     return 1;
541     }
542     else
543     {
544     return 0;
545     }
546     if (kd[n - 2]->c[0] == key[n - 2])
547     return 1;
548     else
549     return 0;
550     }
551     else if (1 <= n && n < 5 && kd[n - 1])
552     {
553     unsigned c2 = kd[n - 1]->c[0];
554     if ((0x81 <= c2 && c2 <= 0x9F)
555     || (0xE0 <= c2 && c2 <= 0xFC))
556     {
557     kd[n - 1] = NULL;
558     #if 0
559     if (!(n == 1 && n == 2))
560     key[n] &= 0x7F;
561     if (!(n == 2 && n == 3))
562     key[n - 1] &= 0x7F;
563     #endif
564     key_make_map(n - 1);
565     }
566     else if ((key[n - 1] & 0x7F) == ((kd[n - 1] + 1)->c[0] & 0x7F))
567     {
568     memcpy(&key[n - 1], &(++kd[n - 1])->c[0], 4);
569     #if DEBUG>=2
570     printf(">dt_get:%c%c%c%c(%02X%02X:%02X%02X)\n",
571     kd[n - 1]->c[0], kd[n - 1]->c[1], kd[n - 1]->c[2], kd[n - 1]->c[3],
572     kd[n - 1]->c[0], kd[n - 1]->c[1], kd[n - 1]->c[2], kd[n - 1]->c[3]);
573     #endif
574     return 1;
575     }
576     else
577     {
578     return 0;
579     }
580     #if 0
581     if (kd[n - 1]->c[0] == key[n - 1])
582     return 1;
583     else
584     return 0;
585     #endif
586     }
587     else if (n < 4 && kd[n])
588     {
589     if (0 && kd[n]->c[0] == key[n])
590     return 1;
591     kd[n] = NULL;
592     #if 0
593     if (!(n == 1 || n == 2))
594     key[n] &= 0x7F;
595     #endif
596     }
597 chapuni 39 #endif
598 chapuni 1
599     /* ŽŔŰ‚É‘‚₾‚Ă݂é */
600     assert(n >= 3);
601     for (;;)
602     {
603     if (n <= 3
604     && !(key[n] & 0x80)
605     && kcls[n].map[key[n] ^ 0x80] & (KCLS_DT0))
606     {
607     /* ”źŠpƒJƒ^ƒJƒi‚Ě1ƒoƒCƒg–Ú */
608     key[n] ^= 0x80;
609     }
610     else
611     {
612     key[n] = (key[n] & 0x7F) + 1;
613     if (key[n] >= 0x80)
614 notanpe 148 {
615     key[n] = 0xFF; /* ŽŸ‚ɓ˓ü‚ł‚š‚Č‚˘‚˝‚ß */
616     return 0;
617     }
618 chapuni 1 }
619    
620     if (kcls[n].map[key[n]])
621     {
622 notanpe 148 key_make_map(key, n);
623     key_reset(key, n + 1);
624 chapuni 1 return 1;
625     }
626     }
627     }
628    
629     /* ŒŽ‚đŠŽ‘S‚ÉƒŠƒZƒbƒg‚ˇ‚é
630     Salt‚ŕƒZƒbƒg‚ľ’ꂎ */
631     static
632     void
633 notanpe 148 key_init(uint8_t *key)
634 chapuni 1 {
635     int i, j;
636    
637     #if USE_DT
638     /* ŽŤ‘‚đAƒCƒ“ƒfƒNƒX‚đě‚č‚Č‚Ş‚çƒ}ƒbƒv‚ɂ͂߂ą‚ń‚ŐŔ‚­
639     ŽŤ‘‚̓R[ƒh‡¸‡‚É•Ŕ‚ń‚Ĺ‚é‚ŕ‚̂Ƃˇ‚é */
640     for (i = 0; i < dtcnt; i++)
641     {
642     unsigned c = dt[i].c[0];
643    
644     assert(dt[i].c[0]
645     && dt[i].c[1]
646     && dt[i].c[2]
647     && dt[i].c[3]);
648    
649     /* BSD ŽI‚Ĺ‚ľ‚É‚ť‚¤‚Č•śŽš‚ÍŽc”O‚Č‚Ş‚çœŠO */
650     assert((dt[i].c[0] & 0x7F)
651     && (dt[i].c[1] & 0x7F)
652     && (dt[i].c[2] & 0x7F)
653     && (dt[i].c[3] & 0x7F));
654    
655     /* ƒCƒ“ƒfƒNƒX */
656     if (!dtidx[c])
657     dtidx[c] = &dt[i];
658    
659     if ((0x81 <= c && c <= 0x9F)
660     || (0xE0 <= c && c <= 0xFC))
661     {
662     /* ‘SŠp‚Ȃ̂ŁA2ƒoƒCƒg‚Ť‚Ü‚Á‚˝Žž“_‚Ĺ—§‚Ä‚é */
663     cp932[256 * c + dt[i].c[1]] |= KCLS_DT1;
664     }
665     else if (0xA1 <= c && c <= 0xDF)
666     {
667     /* ”źŠpƒJƒi */
668     for (j = 0; j < 256; j++)
669     cp932[256 * c + j] |= KCLS_DT0;
670     }
671     }
672     /* ƒPƒcA‚ż‚¤‚Š”Ôl */
673     dtidx[0x100] = &dt[i];
674     #endif
675    
676     key[8] = 0;
677    
678     /* ‰Šúƒ}ƒbƒv‚đ‘g‚Ţ */
679     for (i = 0; i < 256; i++)
680     {
681     unsigned bm = 0;
682     kcls[0].map[i] = 0;
683     for (j = 0; j < 256; j++)
684     bm |= cp932[256 * i + j];
685     kcls[0].map[i] = bm & (KCLS_AN | KCLS_KA | KCLS_K1
686     | KCLS_DT0
687     );
688     if (i >= 128)
689     kcls[0].map[i - 128] |= kcls[0].map[i];
690     }
691    
692 notanpe 148 key_reset(key, 0);
693 chapuni 1 }
694    
695     /***************************************************************
696     *
697 chapuni 122 * ŒĹ’čƒL[‚̐śŹ
698     *
699     * ˆęŒŠ Big Endian ‚É”ń‘Ήž‚̂悤‚ÉŒŠ‚Ś‚é‚ž‚낤‚Ş
700     * Š‚łɎU‚ç‚΂Á‚Ä‚˘‚é kludge ‚É‚ć‚č
701     * ALU_T ‚Ş 64 ƒrƒbƒg‚Ĺ‚ ‚éŒŔ‚čA‚ą‚ę‚Ĺ–â‘č‚Č‚­“Ž‚­B
702     *
703     */
704    
705     static
706     void
707     key_init_sk(struct KEY *key)
708     {
709     int i, j;
710     int o;
711     uint64_t m;
712    
713     for (i = 5, m = 0xFFFFFFFF00000000ULL;
714     i >= 0;
715     m ^= (m >> (1 << --i)))
716     {
717     o = tr_pc1[7][6 - i] - 1;
718 chapuni 123 #if DEBUG>=2
719 chapuni 122 printf("%d:%d->%2d: %08X%08X\n",
720     N_Q, i, o,
721     (unsigned)(m >> 32),
722     (unsigned)m);
723 chapuni 123 #endif
724 chapuni 122 for (j = 0; j < N_Q; j++)
725     if (o < 28)
726     key->k[0][0][o ].q[j] = key->k[0][1][o ].q[j] = m;
727     else
728     key->k[1][0][o - 28].q[j] = key->k[1][1][o - 28].q[j] = m;
729     }
730     #if N_STRIDE==7
731     /* bit 6 ‚Í Little Endian ‚Ć‚ľ‚Ĉľ‚¤ */
732     o = 0;
733     assert(tr_pc1[7][0] - 1 == o);
734     assert(N_Q == 2);
735     key->k[0][0][o].q[0] = key->k[0][1][o].q[0] = 0x0000000000000000ULL;
736     key->k[0][0][o].q[1] = key->k[0][1][o].q[1] = 0xFFFFFFFFFFFFFFFFULL;
737     #endif
738     }
739    
740     /***************************************************************
741     *
742 chapuni 1 * Salt ‚ĚƒZƒbƒg
743     * ƒIƒyƒ‰ƒ“ƒh‚ĚƒIƒtƒZƒbƒg‚đ‘‚ŤŠˇ‚ڂĉń‚Á‚Ä‚é‚̂ŒˆÓ
744     *
745     */
746    
747     void
748 notanpe 148 set_salt(CODE_T *code,
749 notanpe 192 struct CRYPT64_DESC const *desc,
750 notanpe 148 uint8_t const *k)
751 chapuni 1 {
752     int i, j;
753    
754     for (i = 0; i < 2; i++)
755     {
756     unsigned s = k[1 + i] & 255;
757     if (s > 'z')
758     s = 0;
759     else if (s >= 'a')
760     s = s - 'a' + 2 + 10 + 26;
761     else if (s >= 'A')
762     s = s - 'A' + 2 + 10;
763     else if (s >= '.')
764     s = s - '.';
765     else
766     s = 0;
767    
768     #if DEBUG>=1
769     printf("Salt %d:%3o\n", i, s & 63);
770     #endif
771     for (j = 0; j < 6; j++)
772     {
773     #if DEBUG>=2
774 chapuni 6 //printf("Salt %d:%d %+3d:%+3d",
775     printf("Salt %d:%d %08lX:%08lX",
776 chapuni 1 i, j,
777 notanpe 192 LSALT(desc, code, 0, i, j, 0),
778     LSALT(desc, code, 0, i, j, 24));
779 chapuni 1 #endif
780     if (s & (1 << j))
781     {
782 notanpe 192 LSALT(desc, code, 0, i, j, 0) = sizeof(WS_T) * (((4 * i + j + 15) & 31) - 16);
783     LSALT(desc, code, 0, i, j, 24) = sizeof(WS_T) * (((4 * i + j - 1) & 31) - 16);
784 chapuni 1 }
785     else
786     {
787 notanpe 192 LSALT(desc, code, 0, i, j, 0) = sizeof(WS_T) * (((4 * i + j - 1) & 31) - 16);
788     LSALT(desc, code, 0, i, j, 24) = sizeof(WS_T) * (((4 * i + j + 15) & 31) - 16);
789 chapuni 1 }
790 notanpe 192 LSALT(desc, code, 0, i, j, 12) = sizeof(WS_T) * (((4 * i + j + 7) & 31) - 16);
791     LSALT(desc, code, 0, i, j, 36) = sizeof(WS_T) * (((4 * i + j + 23) & 31) - 16);
792 chapuni 1 #if DEBUG>=2
793 chapuni 6 //printf(" => %+3d:%+3d\n",
794     printf(" => %08lX:%08lX\n",
795 notanpe 192 LSALT(desc, code, 0, i, j, 0),
796     LSALT(desc, code, 0, i, j, 24));
797 chapuni 1 #endif
798     }
799     }
800     }
801    
802 notanpe 192 #define USEC_SEC 1000 /* 1•b */
803    
804 chapuni 1 static
805 notanpe 192 uint64_t
806 notanpe 148 usec(void)
807 notanpe 119 {
808 notanpe 120 uint32_t sec, msec;
809    
810 notanpe 119 #if !defined(WIN32)
811     struct timeval tv;
812     gettimeofday(&tv, NULL);
813 notanpe 120 sec = tv.tv_sec;
814 notanpe 192 msec = tv.tv_usec / (1000000 / USEC_SEC);
815 notanpe 119 #else
816     struct timeb tm;
817     ftime(&tm);
818 notanpe 120 sec = tm.time;
819 notanpe 192 msec = tm.millitm / (1000 / USEC_SEC);
820 notanpe 119 #endif
821 notanpe 120
822 notanpe 192 return (uint64_t)USEC_SEC * sec + msec;
823 notanpe 119 }
824    
825     static
826 chapuni 24 int
827     log_printf(FILE *ofp, char const *fmt, ...)
828     {
829     int r;
830     va_list ap;
831     va_start(ap, fmt);
832 notanpe 204
833     /* MAKAI start */
834     #if 0
835     if ( ofp != nfp ) {
836     vfprintf(stdout, fmt, ap);
837     }
838     #endif /* 0 */
839     /* MAKAI end */
840    
841 chapuni 24 vfprintf(stdout, fmt, ap);
842     r = vfprintf(ofp, fmt, ap);
843     va_end(ap);
844     if (r > 0)
845     return r;
846     perror("log_printf");
847     exit(errno);
848     }
849    
850 chapuni 1 /***************************************************************
851     *
852 notanpe 192 * CPU capabilities ‚đŽć“ž
853     * [XXX] ‚ ‚Ü‚č‚É‚ŕŒĂ‚˘ƒvƒƒZƒbƒT‚Ě‚ą‚Ć‚Íl‚ڂȂ˘B
854 chapuni 1 *
855 notanpe 192 * a[4] = {EAX,EBX,ECX,EDX}
856     *
857 chapuni 1 */
858    
859 notanpe 192 #if defined(__GNUC__)
860    
861     #define cpuid(n,a,b,c,d) \
862     asm("cpuid" \
863     : "=a"(a), "=b"(b), "=c"(c), "=d"(d) \
864     : "a"(n))
865    
866     #elif defined(WIN32)
867    
868     #define cpuid(n,a,b,c,d) \
869     do {int r[4]; __cpuid(r,n); \
870     (a) = r[0]; (b) = r[1]; (c) = r[2]; (d) = r[3];} while (0)
871    
872     #endif
873    
874     static
875     unsigned
876     cpuid_getfflags(void)
877 notanpe 148 {
878 notanpe 192 unsigned a, b, c, d;
879     cpuid(1, a, b, c, d);
880     return d;
881     }
882 chapuni 1
883 notanpe 148 static
884 notanpe 192 int
885     cpuid_issupported(void)
886     {
887     unsigned m = REQUIRED_CAPS;
888     return !((cpuid_getfflags() ^ m) & m);
889     }
890    
891     /***************************************************************
892     *
893     * ƒoƒbƒ`ˆ——pƒpƒPƒbƒg
894     *
895     */
896    
897     static
898 notanpe 148 struct PACKET_CRYPT64 *
899     packet_create(int n, /* ƒpƒPƒbƒg” */
900     int tn, /* ––”ö—v‘f‚ɂĕK—v‚Čƒ[ƒN” */
901     uint8_t const *ini_key)
902     {
903     int i;
904     int siz;
905     void *p;
906 notanpe 192 intptr_t a = 128;
907 notanpe 148 struct PACKET_CRYPT64 *pkts;
908     assert(IS_POWER2(sizeof(struct PACKET_CRYPT64)));
909     assert(n >= 1);
910    
911 notanpe 192 siz = (a - 1
912 notanpe 148 + (n - 1) * sizeof(struct PACKET_CRYPT64)
913     + offsetof(struct PACKET_CRYPT64, param64.hit[tn]));
914     p = calloc(siz, 1);
915     /* ƒoƒ“ƒ_ƒŠ‚ ‚킚 */
916     pkts = (struct PACKET_CRYPT64 *)(((intptr_t)p
917 notanpe 192 + a - 1)
918     & -a);
919 notanpe 148 #if DEBUG>=1
920     fprintf(stderr,
921     "packet(n=%d,tn=%d) %d allocated; %p aligned to %p\n",
922     n, tn,
923     siz, p, pkts);
924     #endif
925    
926     /* “ŕ•”‚̏‰Šú‰ť
927     ƒRƒs[‚ľ‚ĉń‚é‚̂́AŒľ–§‚É‚Í
928     ĹI—v‘f‚ĚƒPƒc‚đ”j‚Á‚Ä‚ľ‚Ü‚¤‚ą‚ƂɂȂé‚Ě‚Ĺ
929     ‚Ç‚¤‚š‘Ź“x‚ŕ—v‹‚ł‚ę‚Č‚˘‚ľƒxƒ^ƒR[ƒh */
930     for (i = 0; i < n; i++)
931     {
932 notanpe 192 int j, k;
933 notanpe 148
934     /* t[16] ‚́A“ŕ•”‰‰ŽZ‚ĹŽg—p‚ˇ‚éAall 1 ‚Ş“ü‚Á‚Ä‚˘‚é */
935     memset(&pkts[i].param64.t[T_INV], -1, sizeof(SLICE));
936    
937     /* ŒĹ’čƒL[‚̐śŹ */
938     key_init_sk(&pkts[i].key64);
939    
940     /* ƒL[ƒXƒPƒWƒ…[ƒ‹‚đ‚ą‚ą‚ɉŸ‚ľž‚߂è‚­
941     ]—ˆ‚Í crypt64.S “ŕ‚ĹŠŽŒ‹‚ˇ‚é‚悤‚Ɉř‚˘‚Ä‚˘‚˝ */
942     for (j = 0; j < 28; j++)
943 notanpe 192 for (k = 0; k < N_ALU; k++)
944     pkts[i].key64.ks[j].a[k] = sizeof(WS_T) * ks_ls[j];
945 notanpe 148
946     /* ”O‚Ě‚˝‚߁AŒŽ‚đ‚ą‚ą‚Ĺ—Ž‚ż’…‚݂è‚­(•s—v?) */
947     for (j = 0; j < 8; j++)
948     key_set64(&pkts[i].key64, j, pkts[i].uk.key[j] = ini_key[j], 0, 0x7F);
949     }
950    
951     return pkts;
952     }
953    
954     /***************************************************************
955     *
956     * thread
957     *
958     */
959    
960     #define NQ_CRYPT 64
961     #define NQ_CMP 32
962    
963     #if defined(__GNUC__)
964    
965     typedef int32_t ATOMWORD_T;
966    
967     #define LOCK_INC(p) \
968     asm volatile ("lock incl %0" \
969     : "=m"(*(p)) \
970     : /*nil*/ \
971     : "memory")
972    
973     #define LOCK_DEC(p) \
974     asm volatile ("lock decl %0" \
975     : "=m"(*(p)) \
976     : /*nil*/ \
977     : "memory")
978    
979     #define LOCK_CAS(pd,s,r) \
980     ({ ATOMWORD_T a; \
981     asm volatile ("lock cmpxchg %2,%1" \
982     : "=a"(a) \
983     : "m"(*(pd)), "r"(s), "0"(r) \
984     : "memory");a;})
985    
986     #define LOCK_CASP(pd,s,r) \
987     ({ void *a; \
988     asm volatile ("lock cmpxchg %2,%1" \
989     : "=a"(a) \
990     : "m"(*(pd)), "r"(s), "0"(r) \
991     : "memory");a;})
992    
993     #elif defined(WIN32)
994    
995     typedef LONG ATOMWORD_T;
996    
997     #define LOCK_INC(p) InterlockedIncrement((LONG *)(p))
998     #define LOCK_DEC(p) InterlockedDecrement((LONG *)(p))
999     #define LOCK_CAS(pd,s,r) InterlockedCompareExchange((LONG *)(pd), s, r)
1000     #define LOCK_CASP(pd,s,r) InterlockedCompareExchangePointer((PVOID *)(pd), (PVOID)(s), (PVOID)r)
1001    
1002     #else
1003     #error "configuration not implemented"
1004     #endif
1005    
1006     #if defined(WIN32)
1007    
1008     typedef DWORD THREAD_TIMEOUT_T;
1009    
1010     #define THREAD_INFINITE INFINITE
1011    
1012     typedef HANDLE THREAD_TH_T;
1013     typedef HANDLE THREAD_EV_T;
1014    
1015     #define thread_sleep(n) Sleep(n)
1016     #define thread_create(th, proc, arg) {(th) = (HANDLE)_beginthread(proc, 8192, arg);}
1017     #define thread_create_event(ev, f) {(ev) = CreateEvent(NULL, TRUE, f, NULL);}
1018     #define thread_signal_event(ev) SetEvent(ev)
1019     #define thread_clear_event(ev) ResetEvent(ev)
1020     #define thread_get_tid() GetCurrentThread()
1021     #define thread_set_priority(tid,n) SetThreadPriority(tid, n)
1022 notanpe 200 #if 0
1023     #undef thread_set_priority /* MAKAI */
1024     #endif
1025 notanpe 148 #define thread_set_affinity(tid,m) SetThreadAffinityMask(tid, (DWORD_PTR)1 << (m))
1026    
1027     static
1028 chapuni 1 int
1029 notanpe 148 thread_wait_event(THREAD_EV_T ev, DWORD tmo)
1030     {
1031     DWORD r = WaitForSingleObject(ev, tmo);
1032     return (r < 0
1033     ? r
1034     : (r == WAIT_TIMEOUT
1035     ? -1
1036     : r));
1037     }
1038    
1039 notanpe 192 #elif defined(_POSIX_SOURCE)
1040 notanpe 148
1041     #include <pthread.h>
1042     #include <unistd.h>
1043    
1044     typedef int THREAD_TIMEOUT_T;
1045    
1046     #define THREAD_INFINITE INT_MAX
1047    
1048     #if defined(THREAD_PRIORITY_BELOW_NOROMAL) || defined(THREAD_PRIORITY_IDLE)
1049     #error "unsupported implementation"
1050     #endif
1051    
1052     #define THREAD_PRIORITY_NORMAL 14
1053     #define THREAD_PRIORITY_BELOW_NORMAL 15
1054     #define THREAD_PRIORITY_IDLE 16
1055    
1056     typedef pthread_t THREAD_TH_T;
1057     typedef struct
1058     {
1059     pthread_mutex_t m;
1060     pthread_cond_t c;
1061     int volatile f;
1062     } THREAD_EV_T;
1063    
1064     #define thread_sleep(n) (usleep(1000 * (n)) != EINVAL || sleep((n) / 1000))
1065     #define thread_create(th, proc, arg) thread_create_p(&(th), proc, arg)
1066     #define thread_create_event(ev, f) thread_create_event_p(&(ev), f)
1067     #define thread_signal_event(ev) thread_set_event_p(&(ev), 1)
1068     #define thread_clear_event(ev) thread_set_event_p(&(ev), 0)
1069     #define thread_wait_event(ev,tmo) thread_wait_event_p(&(ev), tmo)
1070    
1071     static
1072     void
1073     thread_create_p(pthread_t *th, NORETURN (*proc)(void *), void *param)
1074     {
1075     pthread_create(th, NULL, (void *(*)(void *))proc, param);
1076     }
1077    
1078     static
1079     void
1080     thread_create_event_p(THREAD_EV_T *ev, int f)
1081     {
1082     ev->f = f;
1083     pthread_cond_init(&ev->c, NULL);
1084     pthread_mutex_init(&ev->m, NULL);
1085     }
1086    
1087     static
1088     void
1089     thread_set_event_p(THREAD_EV_T *ev, int f)
1090     {
1091     pthread_mutex_lock(&ev->m);
1092     if (ev->f != f)
1093     {
1094     ev->f = f;
1095     pthread_cond_broadcast(&ev->c);
1096     }
1097     pthread_mutex_unlock(&ev->m);
1098     }
1099    
1100     static
1101     int
1102     thread_wait_event_p(THREAD_EV_T *ev, int a_tmo)
1103     {
1104     int timeout = a_tmo;
1105     struct timeval now;
1106     struct timespec tmo;
1107     int r;
1108    
1109     pthread_mutex_lock(&ev->m);
1110    
1111     /* ŒťÝŽž‚Š‚çƒ^ƒCƒ€ƒAƒEƒgŽž‚đ‹‚ß‚é
1112     ‚ß‚ń‚Ç‚­‚š[ */
1113     gettimeofday(&now, NULL);
1114     tmo.tv_sec = now.tv_sec + (timeout / 1000);
1115     timeout %= 1000;
1116     timeout *= 1000;
1117     if (now.tv_usec >= 1000000 - timeout)
1118     {
1119     timeout -= 1000000;
1120     tmo.tv_sec++;
1121     }
1122     tmo.tv_nsec = 1000 * (now.tv_usec + timeout);
1123     r = 0;
1124     while (!ev->f)
1125     {
1126     r = pthread_cond_timedwait(&ev->c, &ev->m, &tmo);
1127     if (r == ETIMEDOUT
1128     && a_tmo < THREAD_INFINITE)
1129     break;
1130     }
1131    
1132     pthread_mutex_unlock(&ev->m);
1133    
1134     return (r == ETIMEDOUT
1135     ? (ETIMEDOUT < 0 ? ETIMEDOUT : -1)
1136     : 0);
1137     }
1138    
1139     #if defined(__linux__)
1140    
1141     /* ƒfƒtƒHƒ‹ƒgƒXƒPƒWƒ…[ƒŠƒ“ƒOƒ|ƒŠƒV[‚Ĺ‚Í
1142     —Dć“xÝ’肾‚˝‚čƒAƒCƒhƒ‹ƒXƒŒƒbƒh‹N‚ą‚ľ‚Ä‚ŕ
1143     ‚¨‚ŕ‚ľ‚ë‚­‚Č‚˘‚̂ŁA‚ť‚̂ւń‚͍ĄŒă‚ĚŒ¤‹†‰Ű‘čB */
1144    
1145     #include <linux/unistd.h>
1146     _syscall0(pid_t,gettid)
1147    
1148     #define thread_get_tid() gettid()
1149    
1150     static
1151     int thread_set_affinity(pid_t tid, int i)
1152     {
1153     cpu_set_t m;
1154     CPU_ZERO(&m);
1155     CPU_SET(i, &m);
1156     return sched_setaffinity(tid, sizeof(m), &m);
1157     }
1158    
1159     #else
1160    
1161     /* POSIX ‚ł́AƒXƒŒƒbƒh’PˆĘ‚ĚƒXƒPƒWƒ…[ƒŠƒ“ƒO‚ɉî“ü‚Ĺ‚Ť‚Č‚˘B */
1162    
1163     #endif
1164    
1165     #else
1166     #error "configuration not supported"
1167     #endif
1168    
1169     struct THREAD_PARAM
1170     {
1171     /* ˆČ‰ş‚Í‹¤’ʏî•ń‚ĚƒRƒs[ */
1172     CODE_T *code;
1173 notanpe 192 THREAD_EV_T *p_ev_ks_activated;
1174 notanpe 148 ATOMWORD_T volatile *p_nidle; /* ‘Ň‚ż‚É“ü‚Á‚˝‚瑝‰Á */
1175    
1176     /* ˆČ‰ş‚̓XƒŒƒbƒhŒĹ—L */
1177     #ifdef thread_set_priority
1178     THREAD_TH_T th;
1179     int pri;
1180     #endif
1181     };
1182    
1183     static
1184     volatile ATOMWORD_T wp_crypt, rp_crypt;
1185     static
1186     struct PACKET_CRYPT64 *volatile q_crypt[NQ_CRYPT];
1187    
1188     static
1189     volatile ATOMWORD_T wp_cmp, rp_cmp;
1190     static
1191     struct PACKET_CRYPT64 *volatile q_cmp[NQ_CMP];
1192    
1193     static
1194     uint64_t
1195     thread_avail(void)
1196     {
1197     #if !USE_MT
1198    
1199     return 0x1U;
1200    
1201     #elif defined(WIN32) /* Win32 API */
1202     DWORD_PTR mask, mask_s;
1203     if (!GetProcessAffinityMask(GetCurrentProcess(),
1204     &mask,
1205     &mask_s)
1206     || !mask
1207     || !mask_s)
1208     return 0x1U;
1209     #if DEBUG>=1
1210     fprintf(stderr,
1211     "m=%08X s=%08X\n",
1212     (unsigned)mask,
1213     (unsigned)mask_s);
1214     #endif
1215     if (popcnt64(mask_s) == 1)
1216     /* ‰˝‚ŕŒž‚¤‚Ü‚˘ */;
1217     else if (mask == mask_s)
1218     fprintf(stderr,
1219     "’ʏí‚Ě%d”{‚Ƃ͂悭Œž‚Á‚˝‚ŕ‚̂łˇB\n",
1220     popcnt64(mask));
1221     else
1222     fprintf(stderr,
1223     "Ĺ‚‘Ź—Í‚Ě%g”{‚̗͂łĂŤ‚Ć‚¤‚ɂނń‚΂é‚ćB\n",
1224     (double)popcnt64(mask) / popcnt64(mask_s));
1225     return mask;
1226    
1227     #elif defined(__linux__) /* sched.h Šg’Ł */
1228    
1229     int i;
1230     uint64_t m = 0;
1231     cpu_set_t am;
1232     if (sched_getaffinity(getpid(), sizeof(am), &am) < 0)
1233     return 0x1U;
1234    
1235     for (i = 0; i < 64 && i < CPU_SETSIZE; i++)
1236     if (CPU_ISSET(i, &am))
1237     m |= 1ULL << i;
1238    
1239     return m;
1240     #else
1241    
1242     /* XXX ƒvƒƒZƒbƒT”‚đ’˛‚×ă‚°‚Ä‚­‚ž‚ł‚˘ */
1243     return 0x01U;
1244    
1245     #endif
1246     }
1247    
1248     static
1249     NORETURN
1250     thread_crypt64(void *a_param)
1251     {
1252     struct THREAD_PARAM *param = a_param;
1253     CODE_T *code = param->code;
1254     struct PACKET_CRYPT64 *pkt;
1255     #ifdef thread_set_priority
1256     THREAD_TH_T th = thread_get_tid();
1257     thread_set_priority(th, param->pri);
1258     #endif
1259    
1260     for(;;)
1261     {
1262     ATOMWORD_T rp;
1263     ATOMWORD_T wp;
1264    
1265     /* ƒLƒ…[‚Š‚ç—v‹‚đŽć‚čo‚ˇ */
1266     for (;;)
1267     {
1268     while ((rp = rp_crypt,
1269     WRAP(wp_crypt, NQ_CRYPT) == WRAP(rp, NQ_CRYPT)
1270     /*|| q_crypt[WRAP(rp, NQ_CRYPT)] == NULL*/))
1271     {
1272     THREAD_TIMEOUT_T tmo = (WRAP(wp_crypt, NQ_CRYPT) == WRAP(rp, NQ_CRYPT)
1273     ? THREAD_INFINITE
1274     : 1);
1275     int r;
1276    
1277 notanpe 192 /* Q‚˝ */
1278 notanpe 148 if (tmo == THREAD_INFINITE)
1279     {
1280     LOCK_INC(param->p_nidle);
1281     }
1282    
1283     /* —v‹‘Ň‚ż */
1284 notanpe 192 r = thread_wait_event(*param->p_ev_ks_activated, tmo);
1285 notanpe 148
1286     if (tmo == THREAD_INFINITE)
1287     {
1288     /* ‹N‚ą‚ł‚ę‚˝ */
1289     LOCK_DEC(param->p_nidle);
1290     }
1291     else if (r >= 0)
1292     {
1293     /* ‚ŕ‚¤‚ż‚ĺ‚Á‚ƐQ‚Ă݂é */
1294     thread_sleep(tmo);
1295     }
1296    
1297     /* ŽŠ‚ç‚Ě—Dć“x‚đ–ß‚ˇ
1298     (ŠO‚Š‚çƒu[ƒXƒg‚ł‚ę‚Ă邊‚ŕ) */
1299     #ifdef thread_set_priority
1300     if (r >= 0)
1301     thread_set_priority(th, param->pri);
1302     #endif
1303     }
1304    
1305     if (LOCK_CAS(&rp_crypt, rp + 1, rp) != rp)
1306     continue;
1307     rp = WRAP(rp, NQ_CRYPT);
1308     break;
1309     }
1310    
1311     pkt = q_crypt[rp];
1312     assert(pkt != NULL);
1313     pkt = LOCK_CASP(&q_crypt[rp], NULL, pkt);
1314     assert(pkt != NULL);
1315    
1316     /* ŽŔs‚ľ‚Ă݂é */
1317     CALL_CRYPT64(code, &pkt->key64, &pkt->param64);
1318    
1319     /* Œ‹‰Ę‚đƒLƒ…[‚É‚˝‚˝‚Ťž‚Ţ */
1320     for (;;)
1321     {
1322     while ((wp = wp_cmp,
1323     WRAP(rp_cmp - 1, NQ_CMP) == WRAP(wp, NQ_CMP))
1324     || q_cmp[WRAP(wp, NQ_CMP)] != NULL)
1325     {
1326     #if DEBUG>=1
1327     fprintf(stderr,
1328     "q_cmp stalled(%d,%d) %p\n",
1329     (unsigned)WRAP(wp, NQ_CMP),
1330     (unsigned)WRAP(rp_cmp - 1, NQ_CMP),
1331     q_cmp[WRAP(wp, NQ_CMP)]);
1332     #endif
1333     thread_sleep(1);
1334     }
1335    
1336     if (LOCK_CAS(&wp_cmp, wp + 1, wp) != wp)
1337     continue;
1338     wp = WRAP(wp, NQ_CMP);
1339     break;
1340     }
1341    
1342     pkt = LOCK_CASP(&q_cmp[wp], pkt, NULL);
1343     assert(pkt == NULL);
1344     }
1345     }
1346    
1347 notanpe 197 /* MAKAI start */
1348     void
1349     usage( path )
1350     char *path;
1351     {
1352     char *myName, *chPtr;
1353    
1354     myName = basename( path );
1355     for ( chPtr = myName; *chPtr != '\0'; chPtr++ ) {
1356     if ( *chPtr == '.' ) {
1357     *chPtr = '\0';
1358     break;
1359     }
1360     }
1361 notanpe 203 printf( "%s [-t num|-m mask] [-s num] [-v] [\"str\"]\n", myName );
1362 notanpe 197 printf( " -t num : ŒŸőƒXƒŒƒbƒh” ( %d … num … %d )\n",
1363     MIN_THREAD, MAX_THREAD );
1364 notanpe 199 printf( " -m mask : ŽŔs‚ˇ‚é CPU ‚đŽw’股‚éƒ}ƒXƒN ( 1 ƒrƒbƒg … mask ‚Ěƒrƒbƒg” … %d ƒrƒbƒg )\n",
1365     MAX_THREAD );
1366 notanpe 202 printf( " y-t ‚Ć -m ‚Í”r‘źz\n" );
1367 notanpe 203 printf( " -s num : —”‚ĚŽí ( 1 … num … %u )\n", UINT_MAX );
1368     printf( " -v : ç’ˇƒƒbƒZ[ƒW\n" );
1369 notanpe 197 printf( " str : ć“ނɖ„‚ߍž‚Ţ•śŽš—ń ( %d … str ‚ĚƒoƒCƒg” … %d )\n",
1370     MIN_UME, MAX_UME );
1371     }
1372 notanpe 198
1373     /* ƒqƒbƒgŽž‚ɂ͏o—̓tƒ@ƒCƒ‹‚Ö‚Ěƒ|ƒCƒ“ƒ^‚đ•Ô‚ˇ */
1374     FILE *
1375 notanpe 202 checkSpecial( trip, kind )
1376 notanpe 198 char *trip;
1377 notanpe 202 unsigned char *kind;
1378 notanpe 198 {
1379 notanpe 202 if ( special & ST_BUOO ) {
1380     /* ‚Ô‚¨ [A-Za-z]aoo[A-Za-z]uoo$ */
1381     if ( trip[3] == 'a' && trip[4] == 'o' && trip[5] == 'o' &&
1382     trip[7] == 'u' && trip[8] == 'o' && trip[9] == 'o' &&
1383     isalpha( trip[2] ) && isalpha( trip[6] ) ) {
1384     strcpy( kind, "‚Ô" );
1385 notanpe 198 return( tfp );
1386     }
1387     }
1388    
1389     if ( special & ST_NIKO ) {
1390     /* “ń\ */
1391     int i;
1392     char ch1, ch2;
1393    
1394     ch1 = trip[0];
1395     for ( i = 1; i < TRIP_LEN; i++ ) {
1396     if ( trip[i] != ch1 ) break;
1397     }
1398     ch2 = trip[i];
1399     for ( ; i < TRIP_LEN; i++ ) {
1400     if ( trip[i] != ch1 && trip[i] != ch2 ) goto NONIKO;
1401     }
1402 notanpe 202 strcpy( kind, "“ń" );
1403 notanpe 198 return( tfp );
1404     }
1405     NONIKO:
1406    
1407 notanpe 202 if ( special & ST_ALLN ) {
1408 notanpe 204 /* ‘S” ‚Š “{” */
1409 notanpe 202 if ( isdigit( trip[0] ) && isdigit( trip[1] ) && isdigit( trip[2] ) &&
1410     isdigit( trip[3] ) && isdigit( trip[4] ) && isdigit( trip[5] ) &&
1411     isdigit( trip[6] ) && isdigit( trip[7] ) && isdigit( trip[8] ) &&
1412     isdigit( trip[9] ) ) {
1413 notanpe 204 if ( special & ST_DOSU ) {
1414     /* ‘S” & ‰ń•ś */
1415     if ( trip[0] == trip[9] && trip[1] == trip[8] && trip[2] == trip[7] &&
1416     trip[3] == trip[6] && trip[4] == trip[5] ) {
1417     strcpy( kind, "“{" );
1418     return( tfp );
1419     }
1420     /* ‘S” & ‘o˜A */
1421     if ( trip[0] == trip[1] && trip[2] == trip[3] && trip[4] == trip[5] &&
1422     trip[6] == trip[7] && trip[8] == trip[9] ) {
1423     strcpy( kind, "“{" );
1424     return( tfp );
1425     }
1426     /* ‘S” & ŽR•F */
1427     if ( trip[0] == trip[5] && trip[1] == trip[6] && trip[2] == trip[7] &&
1428     trip[3] == trip[8] && trip[4] == trip[9] ) {
1429     strcpy( kind, "“{" );
1430     return( tfp );
1431     }
1432     /* ĹŹ‚˂炢 */
1433     if ( trip[0] == '0' && trip[1] == '0' && trip[2] == '0' &&
1434     trip[3] == '0' && trip[4] == '0' && trip[5] == '0' &&
1435     trip[6] == '0' ) {
1436     strcpy( kind, "“{" );
1437     return( tfp );
1438     }
1439     /* Ĺ‘ĺ‚˂炢 */
1440     if ( trip[0] == '9' && trip[1] == '9' && trip[2] == '9' &&
1441     trip[3] == '9' && trip[4] == '9' && trip[5] == '9' &&
1442     trip[6] == '9' ) {
1443     strcpy( kind, "“{" );
1444     return( tfp );
1445     }
1446     } else {
1447     strcpy( kind, "”" );
1448     return( nfp );
1449     }
1450 notanpe 202 }
1451     }
1452    
1453 notanpe 198 return( NULL );
1454     }
1455 notanpe 197 /* MAKAI end */
1456    
1457 notanpe 148 /***************************************************************
1458     *
1459     * ƒƒCƒ“ƒ‹[ƒv‚Ć‚Š
1460     *
1461     */
1462    
1463     int
1464 chapuni 1 main(int argc, char *argv[])
1465     {
1466 chapuni 74 int i;
1467 chapuni 1 int mincnt;
1468 chapuni 77 int nblk_hit, nblk_total;
1469 chapuni 84 int nap_hit, nap_total;
1470 notanpe 148 CODE_T *code = NULL;
1471     off_t code_cmp;
1472 chapuni 1 FILE *ofp;
1473 chapuni 46 FILE *sfp; /* scoreboard */
1474     struct ITREE *root_expr;
1475 notanpe 148 uint64_t proc_mask;
1476     int ks_activated;
1477 notanpe 192 static THREAD_EV_T event_ks_activated;
1478 notanpe 148 static ATOMWORD_T volatile nidle;
1479     struct THREAD_PARAM *threads = NULL;
1480     int nthreads;
1481     int npkts;
1482     struct PACKET_CRYPT64 *pkts, *pkt_hit;
1483     uint64_t pkts_vacant;
1484     int tn;
1485 chapuni 1 int cr;
1486    
1487 notanpe 148 /* ŒŽ•śŽš—ń */
1488     uint8_t key[8 + 8];
1489    
1490 chapuni 74 int xhash_loaded;
1491    
1492 notanpe 119 #define UPDATE_INTERVAL 8 /* ‘Ź“x•\ŽŚ‚ĚŠÔŠu •b */
1493 notanpe 115 struct status {
1494 notanpe 192 uint64_t startTime; /* ŠJŽnŽž ƒ~ƒŠ•b */
1495     uint64_t lastTime; /* ĹŒă‚É•\ŽŚ‚ľ‚˝Žž ƒ~ƒŠ•b */
1496     uint64_t loop; /* ‘ŒŸőŒÂ” */
1497     uint64_t lastloop; /* ĹŒă‚É•\ŽŚ‚ľ‚˝Žž‚Ě loop */
1498 notanpe 115 } status;
1499 notanpe 192 uint64_t curTime;
1500     uint32_t upd_int = 0;
1501 chapuni 1
1502 notanpe 193 /* MAKAI start */
1503 notanpe 197 /* ŽŔŰ‚̏ˆ—‚Ć‚ ‚Á‚Ä‚˘‚Č‚˘ƒRƒƒ“ƒg‚đíœ */
1504    
1505 notanpe 193 #if defined(WIN32)
1506     SetPriorityClass( GetCurrentProcess(), IDLE_PRIORITY_CLASS );
1507     #endif
1508 notanpe 197
1509     {
1510     int optChar;
1511     extern char *optarg;
1512     extern int optind;
1513 notanpe 199 char *chPtr;
1514 notanpe 197
1515     nThread = 0;
1516 notanpe 199 pmask = 0;
1517 notanpe 203 seed = 0;
1518     verbose = 0;
1519     while ( (optChar = getopt(argc, argv, "t:m:s:vh")) != EOF ) {
1520 notanpe 197 switch ( optChar ) {
1521     case 't':
1522 notanpe 199 pmask = 0;
1523 notanpe 197 nThread = atoi( optarg );
1524     if ( nThread < MIN_THREAD || nThread > MAX_THREAD ) {
1525     usage( argv[0] );
1526     exit( 1 );
1527     }
1528     break;
1529 notanpe 199 case 'm':
1530     nThread = 0;
1531     if ( strlen( optarg ) > MAX_THREAD ) {
1532     usage( argv[0] );
1533     exit( 1 );
1534     }
1535     for ( chPtr = optarg; *chPtr != '\0'; chPtr++ ) {
1536     pmask <<= 1;
1537     switch ( *chPtr ) {
1538     case '0':
1539     /* ‚Č‚É‚ŕ‚ľ‚Č‚˘ */
1540     break;
1541     case '1':
1542     pmask |= 1;
1543     break;
1544     default:
1545     usage( argv[0] );
1546     exit( 1 );
1547     break;
1548     }
1549     }
1550 notanpe 200 if ( pmask < MIN_THREAD ) {
1551     usage( argv[0] );
1552     exit( 1 );
1553     }
1554 notanpe 199 break;
1555 notanpe 203 case 's':
1556     if ( optarg[0] == '-' ) {
1557     usage( argv[0] );
1558     exit( 1 );
1559     }
1560     seed = (unsigned int)atoi( optarg );
1561     if ( seed < 1 || seed > UINT_MAX ) {
1562     usage( argv[0] );
1563     exit( 1 );
1564     }
1565     break;
1566     case 'v':
1567     verbose = 1;
1568     break;
1569 notanpe 197 case 'h':
1570     usage( argv[0] );
1571     exit( 0 );
1572     break;
1573     }
1574     }
1575    
1576     switch ( argc - optind ) {
1577     case 0:
1578     umeStr[0] = '\0';
1579     umeLen = KEY_SHUFFLE_POS;
1580     break;
1581     case 1:
1582     strcpy( umeStr, argv[optind] );
1583     umeLen = strlen( umeStr );
1584     if ( umeLen < MIN_UME || umeLen > MAX_UME ) {
1585     usage( argv[0] );
1586     exit( 1 );
1587     }
1588     break;
1589     default:
1590     usage( argv[0] );
1591     exit( 1 );
1592     }
1593     }
1594 notanpe 193 /* MAKAI end */
1595    
1596 notanpe 192 if (!cpuid_issupported())
1597 chapuni 1 {
1598 notanpe 192 fprintf(stderr, "‚ą‚̊‹Ť‚Ĺ‘–‚炚‚邹‚Ć‚Ş‘z’肳‚ę‚Ä‚˘‚Ü‚š‚ńB\n");
1599     exit(1);
1600 chapuni 1 }
1601    
1602 chapuni 10 assert((1 << N_STRIDE) == N_ALU * ALU_BITS);
1603    
1604 chapuni 46 /* ƒ^ƒQ“ǂݍž‚Ý */
1605     root_expr = expr_parse("target.txt");
1606 chapuni 2
1607 notanpe 203 /* MAKAI start */
1608     if ( verbose ) {
1609     printf( "“ÁŽęŒŸőƒIƒvƒVƒ‡ƒ“ : " );
1610 notanpe 204 if ( special & ST_DOSU ) {
1611     printf( "“{” " );
1612     } else {
1613     if ( special & ST_ALLN ) {
1614     printf( "‘S” " );
1615     }
1616 notanpe 203 }
1617     if ( special & ST_NIKO ) {
1618     printf( "“ń\ " );
1619     }
1620     if ( special & ST_BUOO ) {
1621     printf( "‚Ô‚¨ " );
1622     }
1623     if ( special ) {
1624     printf( "ƒIƒ“I\n" );
1625     } else {
1626     printf( "ƒI[ƒ‹ƒIƒtI\n" );
1627     }
1628     }
1629     /* MAKAI end */
1630    
1631 notanpe 148 /* ƒR[ƒh‚đśŹE“WŠJ
1632     ‹N“Ž—\’čƒXƒŒƒbƒh”‚ɉž‚ś‚Ä
1633     śŹ‚ˇ‚éƒR[ƒh‚đ•Ď‚Ś‚é */
1634 chapuni 46 sfp = scoreboard_open();
1635 notanpe 192 fwrite(crypt64_descs[0]->pro, 1, crypt64_descs[0]->cmp_pro - crypt64_descs[0]->pro, sfp); /* prologue & ƒRƒAƒ‹[ƒv */
1636 notanpe 197
1637     /* MAKAI start */
1638     if ( nThread == 0 ) {
1639 notanpe 199 if ( pmask == 0 ) {
1640     proc_mask = thread_avail();
1641     } else {
1642 notanpe 205 /* ‚ž‚Ş‚ľ‚Š‚ľAWin32 ‚ĚƒR[ƒh‚ľ‚Š‚ą‚ą‚ɂ͂Ȃ˘B‚— */
1643     #ifdef WIN32
1644     DWORD_PTR processMask, systemMask;
1645     if ( GetProcessAffinityMask( GetCurrentProcess(), &processMask, &systemMask )
1646 notanpe 206 == 0 ) {
1647 notanpe 205 printf( "CPU ‚ĚŠ„‚č“–‚ĂɎ¸”s ‚ť‚Ě 1\n" );
1648     exit( 1 );
1649     }
1650     if ( (processMask & pmask) != pmask ) {
1651     printf( "‚ť‚ń‚Č CPU ‚͂˂ĽI\n" );
1652     exit( 1 );
1653     }
1654     #endif /* WIN32 */
1655 notanpe 199 proc_mask = pmask;
1656 notanpe 200 printf( "CPU : " );
1657     for ( i = 0; i < MAX_THREAD; i++ ) {
1658     if ( pmask & 1 ) {
1659     printf( "%d ", i );
1660     }
1661     pmask >>= 1;
1662     }
1663     printf( "‚đŽg—p‚ľ‚Ü‚ˇB\n" );
1664     #ifdef WIN32
1665 notanpe 205 if ( SetProcessAffinityMask( GetCurrentProcess(), proc_mask ) == 0 ) {
1666     printf( "CPU ‚ĚŠ„‚č“–‚ĂɎ¸”s ‚ť‚Ě 2\n" );
1667     exit( 1 );
1668     }
1669 notanpe 200 #endif /* WIN32 */
1670 notanpe 199 }
1671 notanpe 197 } else {
1672     int i;
1673     proc_mask = 0U;
1674     for ( i = 0; i < nThread; i++ ) {
1675 notanpe 199 proc_mask <<= 1;
1676 notanpe 197 proc_mask |= 1U;
1677     }
1678 notanpe 199 printf( "%d ŒÂ‚ĚŒŸőƒXƒŒƒbƒh‚𐜐Ź\n", nThread );
1679 notanpe 197 }
1680     /* MAKAI end */
1681    
1682 notanpe 200 if (popcnt64(proc_mask) == 1) /* MAKAI */
1683 notanpe 148 {
1684     /* single */
1685     npkts = 1;
1686     pkts_vacant = 1;
1687     code_cmp = 0;
1688     }
1689     else
1690     {
1691     /* multi */
1692 notanpe 192 fwrite(crypt64_descs[0]->ep, 1, crypt64_descs[0]->ep_end - crypt64_descs[0]->ep, sfp); /* epilogue */
1693 chapuni 2
1694 notanpe 148 /* ”äŠrŠí‚݂̂𐜐Ź(‘O”ź) */
1695     code_cmp = ftell(sfp);
1696     fseek(sfp, (-code_cmp) & 63, SEEK_CUR);
1697     code_cmp = ftell(sfp);
1698 notanpe 192 fwrite(crypt64_descs[0]->pro, 1, crypt64_descs[0]->crypt - crypt64_descs[0]->pro, sfp); /* prologue */
1699 notanpe 148 npkts = 64;
1700     pkts_vacant = (uint64_t)-1; /* (1 << 64) - 1 ‚đŒvŽZ‚ľ‚˝‚­‚Č‚˘ */
1701     }
1702    
1703     /* ”äŠr•”‚đśŹ */
1704 notanpe 192 fwrite(crypt64_descs[0]->cmp_pro, 1, crypt64_descs[0]->cmp_ep - crypt64_descs[0]->cmp_pro, sfp); /* ”äŠrŠí€”ő */
1705 notanpe 148 tn = synth_synthesize(sfp, root_expr);
1706 notanpe 192 fwrite(crypt64_descs[0]->cmp_ep, 1, crypt64_descs[0]->ep_end - crypt64_descs[0]->cmp_ep, sfp); /* epilogue */
1707 notanpe 148
1708 chapuni 46 /* ƒR[ƒh‚đƒƒ‚ƒŠ‚É“\‚č•t‚Ż‚é */
1709     code = scoreboard_map(sfp);
1710 chapuni 1
1711     /* ƒL[‚̏‰Šú‰ť */
1712 notanpe 199 /* MAKAI start */
1713 notanpe 203 if ( seed == 0 ) {
1714 notanpe 204 seed = (unsigned int)time( NULL );
1715 notanpe 203 }
1716 notanpe 204 if ( verbose ) {
1717     printf( "—”‚ĚŽí = %u\n", seed );
1718     }
1719     srand( seed );
1720 notanpe 199 /* MAKAI end */
1721 notanpe 148 key_init(key);
1722 notanpe 192 set_salt(code, crypt64_descs[0], key);
1723 chapuni 1
1724 notanpe 148 /* ‰‰ŽZƒpƒPƒbƒg‚đěŹ */
1725     pkts = packet_create(npkts, tn, key);
1726     pkt_hit = &pkts[npkts - 1];
1727    
1728     /* “­‚­‚¨‚ś‚ł‚ń‚đ—ĘŽY */
1729     thread_create_event(event_ks_activated, 1);
1730     ks_activated = 1;
1731     nthreads = 0;
1732     if (code_cmp)
1733     {
1734     THREAD_TH_T h;
1735     int ots = -1;
1736     threads = calloc(2 * popcnt64(proc_mask), sizeof(*threads));
1737     for (i = 0; proc_mask; i++, proc_mask >>= 1)
1738     if (proc_mask & 1)
1739     {
1740     if (ots < 0)
1741     {
1742     /* ŽŠ•ŞŽŠg‚ĚƒXƒPƒWƒ…[ƒŠƒ“ƒO
1743     ‚ą[‚ä[Œn‚ĚƒAƒvƒŠ‚Í’á‚߂ɐݒ股‚é‚Ě‚Ş‹g(‚Š‚ŕ) */
1744     #ifdef WIN32
1745     h = GetCurrentProcess();
1746     SetPriorityClass(h, BELOW_NORMAL_PRIORITY_CLASS);
1747 chapuni 1 #endif
1748 notanpe 148 #if defined(thread_set_priority)
1749     /* S‚ĚŒ„ŠÔ‚¨–„‚ß‚ľ‚Ü‚ˇ */
1750     threads[nthreads].code = code;
1751 notanpe 192 threads[nthreads].p_ev_ks_activated = &event_ks_activated;
1752 notanpe 148 threads[nthreads].p_nidle = &nidle;
1753     threads[nthreads].pri = THREAD_PRIORITY_IDLE;
1754     thread_create(h, thread_crypt64, &threads[nthreads]);
1755     threads[nthreads].th = h;
1756     nthreads++;
1757     #endif
1758     if (!code_cmp)
1759     break;
1760 chapuni 1
1761 notanpe 148 /* ŽŠ•ŞŽŠg‚ĚŽc‚č‚̐ݒč‚đA‚ ‚Ƃłâ‚é */
1762     ots = i;
1763     }
1764     else
1765     {
1766     /* ‘źƒXƒŒƒbƒh‚́A‚â‚â’á‚߂̗Dć“x‚ŁB */
1767     threads[nthreads].code = code;
1768 notanpe 192 threads[nthreads].p_ev_ks_activated = &event_ks_activated;
1769 notanpe 148 threads[nthreads].p_nidle = &nidle;
1770     #ifdef thread_set_priority
1771     threads[nthreads].pri = THREAD_PRIORITY_BELOW_NORMAL;
1772     #endif
1773     thread_create(h, thread_crypt64, &threads[nthreads]);
1774     #ifdef thread_set_priority
1775     threads[nthreads].th = h;
1776     #endif
1777     #ifdef thread_get_tid
1778     thread_set_affinity(h, i);
1779     #endif
1780     nthreads++;
1781     }
1782     }
1783     #ifdef thread_get_tid
1784     if (ots)
1785     thread_set_affinity(thread_get_tid(), ots);
1786     #endif
1787     }
1788    
1789 chapuni 24 if ((ofp = fopen("log.txt", "at")) == NULL)
1790     {
1791     perror("log.txt");
1792     return errno;
1793     }
1794 chapuni 1
1795 chapuni 24 setvbuf(ofp, NULL, _IONBF, BUFSIZ); /* XXX MSVCRT ‚Ĺ‚Í _IOLBF ‚ŞŠú‘Ň’Ę‚č‚É“Žě‚ľ‚Č‚˘ */
1796    
1797 notanpe 198 /* MAKAI start */
1798     if ( (tfp = fopen("logspe.txt", "at")) == NULL ) {
1799     perror("logspe.txt");
1800     return errno;
1801     }
1802     setvbuf( tfp, NULL, _IONBF, BUFSIZ );
1803 notanpe 204 if ( (nfp = fopen("lognum.txt", "at")) == NULL ) {
1804     perror("lognum.txt");
1805     return errno;
1806     }
1807     setvbuf( nfp, NULL, _IONBF, BUFSIZ );
1808 notanpe 198 /* MAKAI end */
1809    
1810 chapuni 1 mincnt = 0x7FFFFFFF;
1811 chapuni 77 nblk_hit = nblk_total = 0;
1812 chapuni 84 nap_hit = nap_total = 0;
1813 chapuni 1 cr = 0;
1814 notanpe 120 memset( &status, 0, sizeof( struct status ) );
1815 notanpe 119 status.startTime = status.lastTime = usec();
1816 chapuni 1 /* ’Tőƒ‹[ƒv‚ž‚ź‚Á‚Ć */
1817     for (;;)
1818     {
1819 notanpe 148 struct PACKET_CRYPT64 *pkt_c;
1820 chapuni 121 uint64_t cnt;
1821 notanpe 205 #if DEBUG>=1 /* MAKAI */
1822 chapuni 121 int cnt1, cnt2;
1823 notanpe 205 #endif /* MAKAI */
1824 chapuni 1 int k, kk;
1825    
1826 notanpe 148 /* ”äŠrŠíŒó•â(may be NULL)
1827     ć‚ɃLƒ…[‚Š‚çŽć‚čo‚ˇ */
1828     pkt_c = q_cmp[WRAP(rp_cmp, NQ_CMP)];
1829 notanpe 192 if (pkt_c != NULL && WRAP(rp_cmp, NQ_CMP) != WRAP(wp_cmp, NQ_CMP))
1830 chapuni 1 {
1831 notanpe 148 pkt_c = LOCK_CASP(&q_cmp[WRAP(rp_cmp, NQ_CMP)], NULL, pkt_c);
1832     assert(pkt_c != NULL);
1833     LOCK_INC(&rp_cmp);
1834    
1835     /* ƒpƒPƒbƒg‚đ vacant ‚ɉń‚ľ‚Ä‚¨‚­ */
1836     pkts_vacant |= 1ULL << (pkt_c - pkts);
1837 chapuni 1 }
1838    
1839 notanpe 148 /* Saltƒ`ƒFƒ“ƒW‘Ň‚ż */
1840     if (!ks_activated)
1841     {
1842 notanpe 192 ATOMWORD_T rp;
1843    
1844     if (pkt_c == NULL)
1845     {
1846     if ((rp = rp_crypt,
1847     WRAP(rp, NQ_CRYPT) != WRAP(wp_crypt, NQ_CRYPT))
1848     && LOCK_CAS(&rp_crypt, rp + 1, rp) == rp)
1849     {
1850     /* !ks_activate ó‘Ԃł́AŽŠ‚ç‚ŕ—v‹ƒLƒ…[‚đ‚â‚Á‚Â‚Ż‚É‚˘‚­ */
1851     rp = WRAP(rp, NQ_CRYPT);
1852     pkt_c = q_crypt[rp];
1853     assert(pkt_c != NULL);
1854     pkt_c = LOCK_CASP(&q_crypt[rp], NULL, pkt_c);
1855     assert(pkt_c != NULL);
1856     assert(pkt_c != pkt_hit);
1857     CALL_CRYPT64(code,
1858     &pkt_c->key64,
1859     &pkt_c->param64);
1860    
1861     /* ƒpƒPƒbƒg‚đ vacant ‚ɉń‚ľ‚Ä‚¨‚­ */
1862     pkts_vacant |= 1ULL << (pkt_c - pkts);
1863     }
1864     else
1865     {
1866     /* ‚â‚͂股‚邹‚Ć‚Ş‚Č‚˘‚̂ł܂Á‚˝‚č‚Ɖ߂˛‚ˇ */
1867     if (nidle != nthreads)
1868     thread_sleep(1);
1869     }
1870     }
1871    
1872 notanpe 148 if (nidle == nthreads)
1873     {
1874     assert(WRAP(rp_crypt, NQ_CRYPT) == WRAP(wp_crypt, NQ_CRYPT));
1875     /* Salt ƒ`ƒFƒ“ƒW‚މ”\ */
1876 notanpe 192 set_salt(code, crypt64_descs[0], key);
1877     if (nthreads)
1878 notanpe 148 thread_signal_event(event_ks_activated);
1879     ks_activated = 1;
1880     }
1881     }
1882    
1883     /* ŒŽ‚đƒLƒ…[‚É‚˝‚˝‚Ťž‚݂܂­‚é */
1884     if (!ks_activated)
1885     {
1886     /* ŒŽ‚đ“o˜^‚ľ‚Č‚˘ */
1887     ;
1888     }
1889     else for (i = npkts - 1; i >= 0; i--)
1890     if (pkts_vacant & (1ULL << i))
1891     {
1892     int j;
1893    
1894     if (i == npkts - 1)
1895     {
1896     /* ‘O’i‚ŁA“­‚­‚¨‚ś‚ł‚ń‚Š‚ç
1897     Œ‹‰Ę‚đ‚ŕ‚ç‚Á‚Ä‚˘‚˝‚çA‰˝‚ŕ‚ľ‚Č‚˘ */
1898     if (pkt_c != NULL)
1899     continue;
1900     }
1901     else
1902     {
1903     /* ‘O’i‚ĹŽć‚čo‚ľ‚˝‚Î‚Š‚č‚Ě
1904     “­‚­‚¨‚ś‚ł‚ń‚́A‘¸d‚ˇ‚é */
1905     if (&pkts[i] == pkt_c)
1906     continue;
1907    
1908     /* queue full ‚Ěę‡‚ÍŒŠ‘—‚é */
1909 notanpe 192 if (WRAP(wp_crypt, NQ_CRYPT) == WRAP(rp_crypt - 16, NQ_CRYPT) /* XXX 16 ‚͂ĂŤ‚Ć‚¤ */
1910 notanpe 148 || q_crypt[WRAP(wp_crypt, NQ_CRYPT)] != NULL)
1911     break;
1912     }
1913    
1914     /* ŒŽ‚ĚƒZƒbƒg */
1915     for (j = 0; j < 8; j++)
1916     {
1917     key_set64(&pkts[i].key64, j, key[j], key[j] ^ pkts[i].uk.key[j], 0);
1918     pkts[i].uk.key[j] = key[j];
1919     }
1920    
1921     if (i == npkts - 1)
1922     {
1923     /* ŽŸ’i‚Ĺ CRYPT64->CMP */
1924     assert(pkt_c == NULL);
1925     pkt_c = &pkts[i];
1926     assert(pkt_c == pkt_hit);
1927     }
1928     else
1929     {
1930     /* ƒLƒ…[‚É‚˝‚˝‚Ťž‚Ţ */
1931     while (LOCK_CASP(&q_crypt[WRAP(wp_crypt, NQ_CRYPT)], &pkts[i], NULL) != NULL)
1932     {
1933     /* ÝŒvă‚Í‚ą‚ą‚É—ˆ‚Č‚˘ */
1934     #if DEBUG>=1
1935     fprintf(stderr,
1936     "[XXX] q_crypt ‚đ‰˜‚ľ‚Ä‚é‚̂͒N‚ž? (rp=%3d, wp=%3d, v=%08X%08X)\n",
1937     (unsigned)WRAP(rp_crypt, NQ_CRYPT),
1938     (unsigned)WRAP(wp_crypt, NQ_CRYPT),
1939     (unsigned)(pkts_vacant >> 32),
1940     (unsigned)pkts_vacant);
1941     thread_sleep(1000);
1942     #endif
1943     thread_sleep(1);
1944     }
1945     LOCK_INC(&wp_crypt);
1946     pkts_vacant ^= 1ULL << i;
1947     assert(!(pkts_vacant & (1ULL << i))); /* í‚ę */
1948     }
1949    
1950     /* ŒŽ‘‰Á‚Í‚ą‚ń‚ȂƂą‚ë‚ɈړŽ! */
1951     assert(ks_activated);
1952 notanpe 197 /* MAKAI start */
1953     if (!key_inc(key, 6) && !key_inc(key, umeLen))
1954     /* MAKAI end */
1955 notanpe 148 {
1956     /* ŒŽ‚ĚƒVƒƒƒbƒtƒ‹
1957     q_crypt ‚ŞŽJ‚Ż‚é‚܂ŁAset_salt() ‚͂łŤ‚Č‚˘ */
1958     #if DEBUG>=1
1959     fprintf(stderr, "********************************SHUFFLE!\n");
1960     #endif
1961 notanpe 192 if (nthreads)
1962     thread_clear_event(event_ks_activated);
1963 notanpe 148 key_reset(key, 0);
1964    
1965     /* ƒLƒ…[‚ĚŒŽ‚ŞŽJ‚Ż‚é‚Ü‚ĹƒAƒCƒhƒ‹ó‘Ô‚É */
1966     ks_activated = 0;
1967    
1968     /* ƒXƒŒƒbƒh‚đƒu[ƒXƒg‚ľ‚ĉń‚é */
1969     #ifdef thread_set_priority
1970     for (j = 0; j < nthreads; j++)
1971     {
1972     assert(threads != NULL);
1973     thread_set_priority(threads[j].th, THREAD_PRIORITY_NORMAL);
1974     }
1975     #endif
1976    
1977     /* ƒ‹[ƒv‘ąs‚Í‚ŕ‚Í‚â•s—v */
1978     break;
1979     }
1980     }
1981    
1982     /* ‚ˇ‚邹‚Ć‚Ş‚Č‚­‚Č‚Á‚Ä‚˘‚éę‡ */
1983     if (pkt_c == NULL)
1984     {
1985     assert(!ks_activated);
1986     continue;
1987     }
1988    
1989 chapuni 14 /* ŒÄ‚Ô!
1990     LR ‰Šú‰ť‚́AƒTƒuƒ‚ƒWƒ…[ƒ‹“ŕ‚ōs‚¤‚ׂľ
1991     FASTCALL ‚ɏ€‚ś‚˝ŒÄ‚яo‚ľ‚Ě‚˝‚߁A
1992     ƒzƒ“ƒg‚Í‚˘‚낢‚냌ƒWƒXƒ^‚Ş”j‰ó‚ł‚ę‚éƒnƒYc‚Č‚ń‚ž‚ށB */
1993 notanpe 148 if (pkt_c != pkt_hit)
1994     {
1995 notanpe 192 assert(code_cmp != 0);
1996 notanpe 148 cnt = CALL_CMP64(code + code_cmp,
1997     pkt_hit->param64.hit,
1998     pkt_c->param64.lr);
1999     }
2000     else
2001     {
2002     /* ‚悤‚â‚­ŽŠƒXƒŒƒbƒh‚ʼnń‚š‚é */
2003     cnt = CALL_CRYPT64(code,
2004     &pkt_c->key64,
2005     &pkt_c->param64);
2006     if (code_cmp)
2007     cnt = CALL_CMP64(code + code_cmp,
2008     pkt_c->param64.hit,
2009     pkt_c->param64.lr);
2010     }
2011 chapuni 42
2012 chapuni 46 #if DEBUG>=1
2013 chapuni 121 cnt2 = (int32_t)(cnt >> 32);
2014     cnt1 = (int32_t)cnt;
2015     if (mincnt > cnt1 && cnt1 > 0)
2016 chapuni 1 {
2017 chapuni 121 mincnt = cnt1;
2018 chapuni 1 if (cr)
2019     fprintf(stderr, "\n");
2020     cr = 0;
2021 chapuni 121 fprintf(stderr, "cycle=%6d/%6d\n", cnt1, cnt2);
2022 chapuni 1 }
2023 chapuni 46 #endif
2024 chapuni 1
2025 notanpe 148 /* ƒqƒbƒg‚ľ‚˝‚Ć‚Ť‚̏ˆ—
2026     key ‚¨‚ć‚Ń lr ‚Í pkt_c ‚É
2027     ‡’v”ť’č‚Í pkt_hit ‚É“ü‚Á‚Ä‚˘‚éƒnƒY */
2028 chapuni 74 xhash_loaded = 0;
2029 chapuni 6 for (kk = 0; kk < N_ALU; kk++)
2030 chapuni 1 {
2031 chapuni 6 ALU_T t;
2032 notanpe 198
2033     /* MAKAI start */
2034     static uint64_t xhash[64];
2035    
2036     if ( special ) {
2037     CALL_TR64( &pkt_c->param64.lr[0][0].q[kk / (N_ALU / N_Q)], xhash );
2038     xhash_loaded = 1;
2039     }
2040     /* MAKAI end */
2041    
2042 chapuni 84 if (!(kk & (N_ALU / N_Q - 1)))
2043 chapuni 77 nblk_total++, xhash_loaded = 0;
2044 chapuni 9
2045 notanpe 198 /* MAKAI start */
2046     if ( special ) {
2047     char hash[16];
2048     uint8_t buf[32];
2049     FILE *lfp;
2050 notanpe 202 unsigned char kind[3];
2051 notanpe 198
2052     for ( k = 0; k < ALU_BITS; k++ ) {
2053     for ( i = 1; i < 11; i++ ) {
2054     unsigned c = 0;
2055    
2056     c = (xhash[(ALU_BITS * kk + k) & 63] >> (6 * (i - 1))) & 0x3F;
2057     hash[i - 1] = C64[c];
2058     }
2059     hash[10] = 0;
2060 notanpe 202 if ( (lfp = checkSpecial( hash, kind )) != NULL ) {
2061 notanpe 198 struct timeb tb;
2062     struct tm *plt;
2063    
2064     ftime( &tb );
2065     plt = localtime( &tb.time );
2066 notanpe 202 buf[0] = '#';
2067     memcpy( buf+1, pkt_c->uk.key, 8 );
2068     buf[9] = buf[10] = 0;
2069     buf[8] = ( buf[8] & - ( 1 << N_STRIDE ) & 0x7F ) + ALU_BITS * kk + k;
2070 notanpe 198 if ( cr ) fprintf( stderr, "\n" );
2071     cr = 0;
2072 notanpe 202 if ( ! translate( buf+1, 0, 1 ) ) {
2073     strcpy( buf, "Žc”O‚Ĺ‚ľ‚˝" );
2074 notanpe 198 }
2075 notanpe 202 log_printf( lfp, "Ÿ%s %s"
2076     "\t%04d/%02d/%02d %02d:%02d:%02d.%03d"
2077     "\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X) %s\n",
2078     hash, buf,
2079     plt->tm_year + 1900, plt->tm_mon + 1, plt->tm_mday,
2080     plt->tm_hour, plt->tm_min, plt->tm_sec, tb.millitm,
2081     buf[0], buf[1], buf[2], buf[3], buf[4],
2082     buf[5], buf[6], buf[7], buf[8], kind );
2083 notanpe 198 }
2084     }
2085     }
2086     /* MAKAI end */
2087    
2088 notanpe 148 t = pkt_hit->param64.hit[HIT_ANY].a[kk];
2089 chapuni 1 if (!t)
2090     continue;
2091 chapuni 9
2092 chapuni 84 nap_total += ALU_BITS;
2093    
2094 chapuni 6 for (k = 0; k < ALU_BITS; k++)
2095 chapuni 1 {
2096 notanpe 198
2097     /* MAKAI start */
2098     #if 0
2099 chapuni 74 static uint64_t xhash[64];
2100 notanpe 198 #endif /* 0 */
2101     /* MAKAI end */
2102    
2103 chapuni 1 char hash[16];
2104 notanpe 148 uint8_t buf[32];
2105 notanpe 192 struct timeb tb;
2106     struct tm *plt;
2107 notanpe 198
2108 notanpe 196 /* MAKAI start */
2109     int hitLen;
2110     /* MAKAI end */
2111 chapuni 9
2112     if (!(t & ((ALU_T)1 << k)))
2113 chapuni 1 continue;
2114 chapuni 9
2115 chapuni 84 nap_hit++;
2116    
2117 chapuni 74 /* “]’u */
2118     if (!xhash_loaded)
2119     {
2120 chapuni 77 nblk_hit++;
2121 notanpe 148 CALL_TR64(&pkt_c->param64.lr[0][0].q[kk / (N_ALU / N_Q)], xhash);
2122 chapuni 74 xhash_loaded = 1;
2123     }
2124    
2125     /* ŽŤ‘‚𒲂ׂé */
2126 notanpe 196 /* MAKAI hitLen ’ljÁ */
2127 notanpe 148 if (!((pkt_hit->param64.hit[HIT_BOOL].a[kk] & ((ALU_T)1 << k))
2128 notanpe 196 || (hitLen = wdict_ishit(pkt_hit->param64.hit,
2129 chapuni 99 kk, k,
2130 notanpe 196 xhash[(ALU_BITS * kk + k) & 0x3F]))))
2131 chapuni 74 continue;
2132    
2133 notanpe 192 /* ƒqƒbƒgŽž; –‚‰ü‘˘‚Ć‚ż‚ĺ‚Á‚Ćˆá‚¤ */
2134     ftime(&tb);
2135     plt = localtime(&tb.time);
2136    
2137 chapuni 1 for (i = 1; i < 11; i++)
2138     {
2139     unsigned c = 0;
2140 chapuni 74 c = (xhash[(ALU_BITS * kk + k) & 63] >> (6 * (i - 1))) & 0x3F; /* XXX */
2141     hash[i - 1] = C64[c];
2142 chapuni 1 }
2143     hash[10] = 0;
2144    
2145 notanpe 148 memcpy(buf, pkt_c->uk.key, 8);
2146 chapuni 1 buf[8] = buf[9] = 0;
2147 chapuni 10 buf[7] = (buf[7] & -(1 << N_STRIDE) & 0x7F) + ALU_BITS * kk + k;
2148 chapuni 1 if (translate(buf, 0, 1))
2149     {
2150     if (cr)
2151     fprintf(stderr, "\n");
2152     cr = 0;
2153 notanpe 148 #if DEBUG>=1
2154     fprintf(stderr, "%3d:", pkt_c - pkts);
2155     #endif
2156 chapuni 24 log_printf(ofp,
2157 notanpe 192 "Ÿ%s #%s"
2158     "\t%04d/%02d/%02d %02d:%02d:%02d.%03d"
2159 notanpe 196 /* MAKAI start */
2160     "\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X) %02d\n",
2161     /* MAKAI end */
2162 chapuni 24 hash,
2163     buf,
2164 notanpe 192 plt->tm_year + 1900,
2165     plt->tm_mon + 1,
2166     plt->tm_mday,
2167     plt->tm_hour,
2168     plt->tm_min,
2169     plt->tm_sec,
2170     tb.millitm,
2171 chapuni 24 buf[0], buf[1], buf[2], buf[3],
2172     buf[4], buf[5], buf[6], buf[7],
2173 notanpe 196 /* MAKAI start */
2174     buf[8], hitLen);
2175     /* MAKAI end */
2176 chapuni 1 }
2177     else
2178     {
2179 notanpe 193 /* MAKAI start */
2180     log_printf( ofp, "Ÿ%s Žc”O‚Ĺ‚ľ‚˝"
2181     "\t%04d/%02d/%02d %02d:%02d:%02d.%03d"
2182 notanpe 196 "\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X) %02d\n",
2183 notanpe 193 hash,
2184     plt->tm_year + 1900, plt->tm_mon + 1, plt->tm_mday,
2185     plt->tm_hour, plt->tm_min, plt->tm_sec, tb.millitm,
2186     buf[0], buf[1], buf[2], buf[3],
2187 notanpe 196 buf[4], buf[5], buf[6], buf[7], buf[8], hitLen );
2188 notanpe 193 /* MAKAI end */
2189    
2190 notanpe 192 #if DEBUG>=1
2191 chapuni 1 if (cr)
2192     fprintf(stderr, "\n");
2193     cr = 0;
2194 notanpe 148 fprintf(stderr, "%3d:", pkt_c - pkts);
2195 chapuni 24 log_printf(ofp,
2196 notanpe 192 "Ÿ%s (%02X %02X %02X %02X %02X %02X %02X %02X )\n",
2197 chapuni 24 hash,
2198     buf[0], buf[1], buf[2], buf[3],
2199 notanpe 192 buf[4], buf[5], buf[6], buf[7]);
2200     #endif
2201 chapuni 1 }
2202     }
2203     }
2204    
2205 notanpe 192 /* ‘Ź“xŒv‘Ş */
2206 notanpe 115 status.loop += N_ALU * ALU_BITS;
2207 notanpe 192 if (status.loop>= status.lastloop + upd_int
2208     && (curTime = usec()) != status.lastTime)
2209 chapuni 1 {
2210 notanpe 192 uint64_t diffTime;
2211 notanpe 120 int a, b, c;
2212 notanpe 119
2213 notanpe 192 /* ’ĘŽZ(’PˆĘ ktrips/sec) */
2214     diffTime = curTime - status.startTime;
2215     a = status.loop / ((1000 / USEC_SEC) * diffTime);
2216    
2217     /* ‹ćŠÔ(’PˆĘ trips/sec) */
2218 notanpe 120 diffTime = curTime - status.lastTime;
2219 notanpe 192 b = USEC_SEC * (status.loop - status.lastloop) / diffTime;
2220    
2221     /* —\‘Ş */
2222     c = UPDATE_INTERVAL * b;
2223    
2224     /* —§‚żă‚Ş‚č‚ȂǁAŒëˇ‚Ş‚ ‚č upd_int ‚ŞŹ‚ł‚ˇ‚Ź‚˝‚Ć‚Ť‚Í
2225     ‚˘‚Ť‚Č‚č‘S•␳‚š‚¸ 1 •b(==b)‚ŽűĘ‚ł‚š‚éB */
2226     upd_int = (upd_int + b < c
2227     ? upd_int + b
2228     : c);
2229    
2230 notanpe 120 status.lastTime = curTime;
2231     status.lastloop = status.loop;
2232 chapuni 77 #if DEBUG>=1
2233 notanpe 119 fprintf(stderr,
2234     "%5d/%5d(%3d%%)",
2235     nblk_hit, nblk_total, 100 * nblk_hit / nblk_total);
2236     nblk_hit = nblk_total = 0;
2237     if (nap_total)
2238     fprintf(stderr,
2239     " %5d/%5d(%3d%%)",
2240     nap_hit, nap_total, 100 * nap_hit / nap_total);
2241     else
2242     fprintf(stderr,
2243     " -----/-----(---%%)");
2244     nap_hit = nap_total = 0;
2245 chapuni 77 #endif
2246 notanpe 119 fprintf( stderr,
2247 notanpe 120 "%6dktrips/s [%6d.%03dktrips/s]\r",
2248     a, b / 1000, b % 1000 );
2249 notanpe 192 cr++;
2250 chapuni 1 }
2251     }
2252    
2253     return 0;
2254     }
2255    
2256 chapuni 2 /*
2257     * Local Variables:
2258     * tab-width: 4
2259     * End:
2260     *
2261     * EOF */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Rev URL

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26