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