| 25 |
#include <unistd.h> |
#include <unistd.h> |
| 26 |
#include <libgen.h> |
#include <libgen.h> |
| 27 |
#include <limits.h> |
#include <limits.h> |
| 28 |
|
#ifdef REON |
| 29 |
|
#ifdef ONI |
| 30 |
|
#include <onigposix.h> |
| 31 |
|
#else /* ONI */ |
| 32 |
|
/* #include <rxposix.h> */ |
| 33 |
|
#include <regex.h> |
| 34 |
|
#endif /* ONI */ |
| 35 |
|
#endif /* REON */ |
| 36 |
/* MAKAI end */ |
/* MAKAI end */ |
| 37 |
|
|
| 38 |
#if defined(WIN32) |
#if defined(WIN32) |
| 77 |
|
|
| 78 |
FILE *nfp; /* 全数 */ |
FILE *nfp; /* 全数 */ |
| 79 |
FILE *tfp; /* ↑以外の特殊検索 */ |
FILE *tfp; /* ↑以外の特殊検索 */ |
| 80 |
|
#ifdef REON |
| 81 |
|
FILE *rfp; /* 正規表現 */ |
| 82 |
|
#endif /* REON */ |
| 83 |
|
|
| 84 |
unsigned int seed; |
unsigned int seed; |
| 85 |
int verbose; |
int verbose; |
| 120 |
#define ST_DOSU 1<<0x9 /* 怒数 */ |
#define ST_DOSU 1<<0x9 /* 怒数 */ |
| 121 |
#define ST_HREN 1<<0xd /* 飛連 */ |
#define ST_HREN 1<<0xd /* 飛連 */ |
| 122 |
|
|
| 123 |
|
#ifdef REON |
| 124 |
|
#define REGEXPLEN 1024 |
| 125 |
|
char regExpStr[REGEXPLEN]; |
| 126 |
|
regex_t regExp; |
| 127 |
|
#endif /* REON */ |
| 128 |
|
|
| 129 |
void |
void |
| 130 |
comment( str ) |
comment( str ) |
| 131 |
char *str; |
char *str; |
| 138 |
case '8': special |= ST_BUOO; break; |
case '8': special |= ST_BUOO; break; |
| 139 |
case '9': special |= (ST_DOSU | ST_ALLN); break; |
case '9': special |= (ST_DOSU | ST_ALLN); break; |
| 140 |
case 'd': special |= ST_HREN; break; |
case 'd': special |= ST_HREN; break; |
| 141 |
|
case 'R': |
| 142 |
|
#ifdef REON |
| 143 |
|
if ( strlen( str ) >= REGEXPLEN ) { |
| 144 |
|
fprintf( stderr, "正規表現 (%s) が長すぎ", str ); |
| 145 |
|
exit( 1 ); |
| 146 |
|
} |
| 147 |
|
strcpy( regExpStr, str + 4 ); |
| 148 |
|
if ( regcomp( ®Exp, regExpStr, REG_NOSUB|REG_EXTENDED ) != 0 ) { |
| 149 |
|
fprintf( stderr, "正規表現 (%s) がおかしい?\n", str ); |
| 150 |
|
exit( 1 ); |
| 151 |
|
} |
| 152 |
|
#else /* REON */ |
| 153 |
|
fprintf( stderr, "このバイナリは、正規表現をサポートしていません。\n" ); |
| 154 |
|
fprintf( stderr, "%s は無視します。\n", str ); |
| 155 |
|
#endif /* REON */ |
| 156 |
|
break; |
| 157 |
} |
} |
| 158 |
} |
} |
| 159 |
} |
} |
| 1633 |
exit( 1 ); |
exit( 1 ); |
| 1634 |
} |
} |
| 1635 |
} |
} |
| 1636 |
|
#ifdef REON |
| 1637 |
|
regExpStr[0] = '\0'; |
| 1638 |
|
#endif /* REON */ |
| 1639 |
/* MAKAI end */ |
/* MAKAI end */ |
| 1640 |
|
|
| 1641 |
if (!cpuid_issupported()) |
if (!cpuid_issupported()) |
| 1673 |
} else { |
} else { |
| 1674 |
printf( "オールオフ!\n" ); |
printf( "オールオフ!\n" ); |
| 1675 |
} |
} |
| 1676 |
|
#ifdef REON |
| 1677 |
|
if ( regExpStr[0] != '\0' ) { |
| 1678 |
|
printf( "正規表現 : %s\n", regExpStr ); |
| 1679 |
|
} |
| 1680 |
|
#endif /* REON */ |
| 1681 |
} |
} |
| 1682 |
/* MAKAI end */ |
/* MAKAI end */ |
| 1683 |
|
|
| 1858 |
return errno; |
return errno; |
| 1859 |
} |
} |
| 1860 |
setvbuf( nfp, NULL, _IONBF, BUFSIZ ); |
setvbuf( nfp, NULL, _IONBF, BUFSIZ ); |
| 1861 |
|
#ifdef REON |
| 1862 |
|
if ( (rfp = fopen("logreg.txt", "at")) == NULL ) { |
| 1863 |
|
perror("logreg.txt"); |
| 1864 |
|
return errno; |
| 1865 |
|
} |
| 1866 |
|
setvbuf( rfp, NULL, _IONBF, BUFSIZ ); |
| 1867 |
|
#endif /* REON */ |
| 1868 |
/* MAKAI end */ |
/* MAKAI end */ |
| 1869 |
|
|
| 1870 |
mincnt = 0x7FFFFFFF; |
mincnt = 0x7FFFFFFF; |
| 1873 |
cr = 0; |
cr = 0; |
| 1874 |
memset( &status, 0, sizeof( struct status ) ); |
memset( &status, 0, sizeof( struct status ) ); |
| 1875 |
status.startTime = status.lastTime = usec(); |
status.startTime = status.lastTime = usec(); |
| 1876 |
|
|
| 1877 |
|
/* MAKAI start */ |
| 1878 |
|
#ifdef MINAST |
| 1879 |
|
#undef assert |
| 1880 |
|
#define assert(x) |
| 1881 |
|
#endif /* MINAST */ |
| 1882 |
|
/* MAKAI end */ |
| 1883 |
|
|
| 1884 |
/* 探索ループだぞっと */ |
/* 探索ループだぞっと */ |
| 1885 |
for (;;) |
for (;;) |
| 1886 |
{ |
{ |
| 2101 |
/* MAKAI start */ |
/* MAKAI start */ |
| 2102 |
static uint64_t xhash[64]; |
static uint64_t xhash[64]; |
| 2103 |
|
|
| 2104 |
if ( special ) { |
if ( special |
| 2105 |
|
#ifdef REON |
| 2106 |
|
|| regExpStr[0] != '\0' |
| 2107 |
|
#endif /* REON */ |
| 2108 |
|
) { |
| 2109 |
CALL_TR64( &pkt_c->param64.lr[0][0].q[kk / (N_ALU / N_Q)], xhash ); |
CALL_TR64( &pkt_c->param64.lr[0][0].q[kk / (N_ALU / N_Q)], xhash ); |
| 2110 |
xhash_loaded = 1; |
xhash_loaded = 1; |
| 2111 |
} |
} |
| 2115 |
nblk_total++, xhash_loaded = 0; |
nblk_total++, xhash_loaded = 0; |
| 2116 |
|
|
| 2117 |
/* MAKAI start */ |
/* MAKAI start */ |
| 2118 |
if ( special ) { |
if ( special |
| 2119 |
char hash[16]; |
#ifdef REON |
| 2120 |
uint8_t buf[32]; |
|| regExpStr[0] != '\0' |
| 2121 |
FILE *lfp; |
#endif /* REON */ |
| 2122 |
unsigned char kind[3]; |
) { |
| 2123 |
|
char hash[16]; |
| 2124 |
for ( k = 0; k < ALU_BITS; k++ ) { |
uint8_t buf[32]; |
| 2125 |
for ( i = 1; i < 11; i++ ) { |
FILE *lfp; |
| 2126 |
unsigned c = 0; |
unsigned char kind[3]; |
| 2127 |
|
|
| 2128 |
|
for ( k = 0; k < ALU_BITS; k++ ) { |
| 2129 |
|
for ( i = 1; i < 11; i++ ) { |
| 2130 |
|
unsigned c = 0; |
| 2131 |
|
|
| 2132 |
c = (xhash[(ALU_BITS * kk + k) & 63] >> (6 * (i - 1))) & 0x3F; |
c = (xhash[(ALU_BITS * kk + k) & 63] >> (6 * (i - 1))) & 0x3F; |
| 2133 |
hash[i - 1] = C64[c]; |
hash[i - 1] = C64[c]; |
| 2134 |
} |
} |
| 2135 |
hash[10] = 0; |
hash[10] = 0; |
| 2136 |
if ( (lfp = checkSpecial( hash, kind )) != NULL ) { |
|
| 2137 |
struct timeb tb; |
#ifdef REON |
| 2138 |
struct tm *plt; |
if ( regExpStr[0] != '\0' ) { |
| 2139 |
|
if ( regexec( ®Exp, hash, (size_t)0, NULL, 0 ) == 0 ) { |
| 2140 |
ftime( &tb ); |
struct timeb tb; |
| 2141 |
plt = localtime( &tb.time ); |
struct tm *plt; |
| 2142 |
buf[0] = '#'; |
uint8_t buf2[32]; |
| 2143 |
memcpy( buf+1, pkt_c->uk.key, 8 ); |
|
| 2144 |
buf[9] = buf[10] = 0; |
ftime( &tb ); |
| 2145 |
buf[8] = ( buf[8] & - ( 1 << N_STRIDE ) & 0x7F ) + ALU_BITS * kk + k; |
plt = localtime( &tb.time ); |
| 2146 |
if ( cr ) fprintf( stderr, "\n" ); |
buf[0] = '#'; |
| 2147 |
cr = 0; |
memcpy( buf+1, pkt_c->uk.key, 8 ); |
| 2148 |
if ( ! translate( buf+1, 0, 1 ) ) { |
buf[9] = buf[10] = 0; |
| 2149 |
strcpy( buf, "残念でした" ); |
buf[8] = ( buf[8] & - ( 1 << N_STRIDE ) & 0x7F ) + ALU_BITS * kk + k; |
| 2150 |
|
if ( cr ) fprintf( stderr, "\n" ); |
| 2151 |
|
cr = 0; |
| 2152 |
|
if ( translate( buf+1, 0, 1 ) ) { |
| 2153 |
|
strcpy( buf2, buf ); |
| 2154 |
|
} else { |
| 2155 |
|
strcpy( buf2, "残念でした" ); |
| 2156 |
|
} |
| 2157 |
|
log_printf( rfp, "◆%s %s" |
| 2158 |
|
"\t%04d/%02d/%02d %02d:%02d:%02d.%03d" |
| 2159 |
|
"\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X) %s\n", |
| 2160 |
|
hash, buf2, |
| 2161 |
|
plt->tm_year + 1900, plt->tm_mon + 1, plt->tm_mday, |
| 2162 |
|
plt->tm_hour, plt->tm_min, plt->tm_sec, tb.millitm, |
| 2163 |
|
buf[1], buf[2], buf[3], buf[4], buf[5], |
| 2164 |
|
buf[6], buf[7], buf[8], buf[9], "正" ); |
| 2165 |
|
} |
| 2166 |
|
} |
| 2167 |
|
#endif /* REON */ |
| 2168 |
|
|
| 2169 |
|
if ( special ) { |
| 2170 |
|
if ( (lfp = checkSpecial( hash, kind )) != NULL ) { |
| 2171 |
|
struct timeb tb; |
| 2172 |
|
struct tm *plt; |
| 2173 |
|
uint8_t buf2[32]; |
| 2174 |
|
|
| 2175 |
|
ftime( &tb ); |
| 2176 |
|
plt = localtime( &tb.time ); |
| 2177 |
|
buf[0] = '#'; |
| 2178 |
|
memcpy( buf+1, pkt_c->uk.key, 8 ); |
| 2179 |
|
buf[9] = buf[10] = 0; |
| 2180 |
|
buf[8] = ( buf[8] & - ( 1 << N_STRIDE ) & 0x7F ) + ALU_BITS * kk + k; |
| 2181 |
|
if ( cr ) fprintf( stderr, "\n" ); |
| 2182 |
|
cr = 0; |
| 2183 |
|
if ( translate( buf+1, 0, 1 ) ) { |
| 2184 |
|
strcpy( buf2, buf ); |
| 2185 |
|
} else { |
| 2186 |
|
strcpy( buf2, "残念でした" ); |
| 2187 |
|
} |
| 2188 |
|
log_printf( lfp, "◆%s %s" |
| 2189 |
|
"\t%04d/%02d/%02d %02d:%02d:%02d.%03d" |
| 2190 |
|
"\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X) %s\n", |
| 2191 |
|
hash, buf2, |
| 2192 |
|
plt->tm_year + 1900, plt->tm_mon + 1, plt->tm_mday, |
| 2193 |
|
plt->tm_hour, plt->tm_min, plt->tm_sec, tb.millitm, |
| 2194 |
|
buf[1], buf[2], buf[3], buf[4], buf[5], |
| 2195 |
|
buf[6], buf[7], buf[8], buf[9], kind ); |
| 2196 |
|
} |
| 2197 |
} |
} |
|
log_printf( lfp, "◆%s %s" |
|
|
"\t%04d/%02d/%02d %02d:%02d:%02d.%03d" |
|
|
"\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X) %s\n", |
|
|
hash, buf, |
|
|
plt->tm_year + 1900, plt->tm_mon + 1, plt->tm_mday, |
|
|
plt->tm_hour, plt->tm_min, plt->tm_sec, tb.millitm, |
|
|
buf[0], buf[1], buf[2], buf[3], buf[4], |
|
|
buf[5], buf[6], buf[7], buf[8], kind ); |
|
| 2198 |
} |
} |
| 2199 |
} |
} |
|
} |
|
| 2200 |
/* MAKAI end */ |
/* MAKAI end */ |
| 2201 |
|
|
| 2202 |
t = pkt_hit->param64.hit[HIT_ANY].a[kk]; |
t = pkt_hit->param64.hit[HIT_ANY].a[kk]; |
| 2216 |
|
|
| 2217 |
char hash[16]; |
char hash[16]; |
| 2218 |
uint8_t buf[32]; |
uint8_t buf[32]; |
| 2219 |
|
uint8_t buf2[32]; |
| 2220 |
struct timeb tb; |
struct timeb tb; |
| 2221 |
struct tm *plt; |
struct tm *plt; |
| 2222 |
|
|
| 2260 |
memcpy(buf, pkt_c->uk.key, 8); |
memcpy(buf, pkt_c->uk.key, 8); |
| 2261 |
buf[8] = buf[9] = 0; |
buf[8] = buf[9] = 0; |
| 2262 |
buf[7] = (buf[7] & -(1 << N_STRIDE) & 0x7F) + ALU_BITS * kk + k; |
buf[7] = (buf[7] & -(1 << N_STRIDE) & 0x7F) + ALU_BITS * kk + k; |
| 2263 |
if (translate(buf, 0, 1)) |
|
|
{ |
|
|
if (cr) |
|
|
fprintf(stderr, "\n"); |
|
|
cr = 0; |
|
|
#if DEBUG>=1 |
|
|
fprintf(stderr, "%3d:", pkt_c - pkts); |
|
|
#endif |
|
|
log_printf(ofp, |
|
|
"◆%s #%s" |
|
|
"\t%04d/%02d/%02d %02d:%02d:%02d.%03d" |
|
|
/* MAKAI start */ |
|
|
"\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X) %02d\n", |
|
|
/* MAKAI end */ |
|
|
hash, |
|
|
buf, |
|
|
plt->tm_year + 1900, |
|
|
plt->tm_mon + 1, |
|
|
plt->tm_mday, |
|
|
plt->tm_hour, |
|
|
plt->tm_min, |
|
|
plt->tm_sec, |
|
|
tb.millitm, |
|
|
buf[0], buf[1], buf[2], buf[3], |
|
|
buf[4], buf[5], buf[6], buf[7], |
|
|
/* MAKAI start */ |
|
|
buf[8], hitLen); |
|
|
/* MAKAI end */ |
|
|
} |
|
|
else |
|
|
{ |
|
| 2264 |
/* MAKAI start */ |
/* MAKAI start */ |
| 2265 |
log_printf( ofp, "◆%s 残念でした" |
/* 見にくいので整理 */ |
| 2266 |
"\t%04d/%02d/%02d %02d:%02d:%02d.%03d" |
if (cr) |
| 2267 |
"\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X) %02d\n", |
fprintf(stderr, "\n"); |
| 2268 |
hash, |
cr = 0; |
| 2269 |
plt->tm_year + 1900, plt->tm_mon + 1, plt->tm_mday, |
if (translate(buf, 0, 1)) { |
| 2270 |
plt->tm_hour, plt->tm_min, plt->tm_sec, tb.millitm, |
buf2[0] = '#'; |
| 2271 |
buf[0], buf[1], buf[2], buf[3], |
strcpy( buf2+1, buf ); |
| 2272 |
buf[4], buf[5], buf[6], buf[7], buf[8], hitLen ); |
} else { |
| 2273 |
|
strcpy( buf2, "残念でした" ); |
| 2274 |
|
} |
| 2275 |
|
log_printf(ofp, "◆%s %s" |
| 2276 |
|
"\t%04d/%02d/%02d %02d:%02d:%02d.%03d" |
| 2277 |
|
"\t(%02X %02X %02X %02X %02X %02X %02X %02X/%02X) %02d\n", |
| 2278 |
|
hash, buf2, |
| 2279 |
|
plt->tm_year + 1900, plt->tm_mon + 1, plt->tm_mday, |
| 2280 |
|
plt->tm_hour, plt->tm_min, plt->tm_sec, tb.millitm, |
| 2281 |
|
buf[0], buf[1], buf[2], buf[3], |
| 2282 |
|
buf[4], buf[5], buf[6], buf[7], |
| 2283 |
|
buf[8], hitLen); |
| 2284 |
/* MAKAI end */ |
/* MAKAI end */ |
| 2285 |
|
|
|
#if DEBUG>=1 |
|
|
if (cr) |
|
|
fprintf(stderr, "\n"); |
|
|
cr = 0; |
|
|
fprintf(stderr, "%3d:", pkt_c - pkts); |
|
|
log_printf(ofp, |
|
|
"◆%s (%02X %02X %02X %02X %02X %02X %02X %02X )\n", |
|
|
hash, |
|
|
buf[0], buf[1], buf[2], buf[3], |
|
|
buf[4], buf[5], buf[6], buf[7]); |
|
|
#endif |
|
|
} |
|
| 2286 |
} |
} |
| 2287 |
} |
} |
| 2288 |
|
|
| 2298 |
diffTime = curTime - status.startTime; |
diffTime = curTime - status.startTime; |
| 2299 |
a = status.loop / ((1000 / USEC_SEC) * diffTime); |
a = status.loop / ((1000 / USEC_SEC) * diffTime); |
| 2300 |
|
|
| 2301 |
|
/* MAKAI start */ |
| 2302 |
|
#ifdef BENCH |
| 2303 |
|
if ( (diffTime / USEC_SEC) > (BENCH * 60) ) { |
| 2304 |
|
fprintf( stderr, "\n%6dktrips/s\n", a ); |
| 2305 |
|
exit( 0 ); |
| 2306 |
|
} |
| 2307 |
|
#endif /* BENCH */ |
| 2308 |
|
/* MAKAI end */ |
| 2309 |
|
|
| 2310 |
/* 区間(単位 trips/sec) */ |
/* 区間(単位 trips/sec) */ |
| 2311 |
diffTime = curTime - status.lastTime; |
diffTime = curTime - status.lastTime; |
| 2312 |
b = USEC_SEC * (status.loop - status.lastloop) / diffTime; |
b = USEC_SEC * (status.loop - status.lastloop) / diffTime; |