Changeset 8 for trunk/src/sh_tiger0.c
- Timestamp:
- Dec 31, 2005, 2:02:03 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_tiger0.c
r1 r8 95 95 SL_TICKET tiger_fd = (-1); 96 96 97 static sh_byte buffer[PRIV_MAX + 72]; 97 98 98 99 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64) … … 108 109 { 109 110 SL_TICKET fd; 110 int i, j ;111 int i, j, tt; 111 112 int count = 0; 112 113 int blk; 113 114 char * tmp; 114 115 sh_byte * bptr; 115 sh_byte buffer[PRIV_MAX + 72];116 /* sh_byte buffer[PRIV_MAX + 72]; */ 116 117 sh_byte bbuf[64]; 118 119 static int lockflag = SL_FALSE; 117 120 118 121 unsigned long pages_read; … … 148 151 SL_ENTER(_("sh_tiger_hash_val")); 149 152 150 if (what == TIGER_FILE || what == TIGER_FD) 151 { 152 if (what == TIGER_FILE) 153 if (what == TIGER_FD || what == TIGER_FILE) 154 { 155 if (what == TIGER_FD) 156 { 157 fd = tiger_fd; 158 TPT((0,FIL__, __LINE__, _("msg=<TIGER_FD>, fd=<%ld>\n"), tiger_fd)); 159 } 160 else 153 161 { 154 162 TPT((0,FIL__, __LINE__, _("msg=<TIGER_FILE>, path=<%s>\n"), 155 163 (filename == NULL ? _("(null)") : filename) )); 156 164 fd = sl_open_read (filename, SL_YESPRIV); 157 }158 else159 {160 fd = tiger_fd;161 TPT((0,FIL__, __LINE__, _("msg=<TIGER_FD>, fd=<%ld>\n"), tiger_fd));162 165 } 163 166 … … 174 177 175 178 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK) 176 if ( skey->mlock_failed == SL_FALSE)179 if (lockflag == SL_FALSE && skey->mlock_failed == SL_FALSE) 177 180 { 178 181 if ( (-1) == sh_unix_mlock((char *)buffer,(PRIV_MAX)*sizeof(sh_byte))) 179 182 skey->mlock_failed = SL_TRUE; 183 lockflag = SL_TRUE; 180 184 } 181 185 #else 182 if (skey->mlock_failed == SL_FALSE) 183 skey->mlock_failed = SL_TRUE; 186 if (lockflag == SL_FALSE && skey->mlock_failed == SL_FALSE) 187 { 188 skey->mlock_failed = SL_TRUE; 189 lockflag = SL_TRUE; 190 } 184 191 #endif 185 192 … … 190 197 pages_read = 0; 191 198 192 while (1 == 1)199 while (1) 193 200 { 194 201 if (timeout > 0) … … 217 224 count, MSG_E_READ, tmp); 218 225 SH_FREE(tmp); 219 (void) sh_unix_munlock((char*)buffer, (PRIV_MAX)*sizeof(sh_byte)); 226 memset (bbuf, 0, 64); 227 memset (buffer, 0, PRIV_MAX); 228 220 229 SL_RETURN( NULL, _("sh_tiger_hash_val")); 221 230 } 222 223 /* TPT((0, FIL__, __LINE__ , _("msg=<Read %ld bytes>\n"), count)); */224 231 225 232 blk = (count / 64); /* number of 64-byte words */ … … 228 235 * count cannot be negative here, see 'if (SL_ISERROR (count))' 229 236 */ 230 ncount = (unsigned long) (count - ((count/64)*64)); 237 tt = blk*64; 238 239 ncount = (unsigned long) (count - tt); 240 241 nblocks += blk; 242 sh.statistics.bytes_hashed += tt; 231 243 232 bptr = buffer; 244 bptr = buffer; tt = 0; 233 245 for (i = 0; i < blk; ++i) 234 246 { 235 bptr = &buffer[ 64 * i];247 bptr = &buffer[tt]; tt += 64; 236 248 237 249 tiger_t(TIGER_CAST bptr, 64, res); 238 ++nblocks;239 sh.statistics.bytes_hashed += 64;240 250 241 251 #ifdef TIGER_DBG … … 252 262 memset (bbuf, 0, 64); 253 263 memset (buffer, 0, PRIV_MAX); 254 (void) sh_unix_munlock( (char *) buffer, 255 (PRIV_MAX) * sizeof(sh_byte)); 264 256 265 SL_RETURN( NULL, _("sh_tiger_hash_val")); 257 266 } … … 268 277 /* copy incomplete block 269 278 */ 270 j = 0; for (i = 0; i < 64; ++i) 271 bbuf[i] = (sh_byte) '\0'; 279 j = 0; 280 for (i = 0; i < 64; i += 4) 281 { 282 bbuf[i] = (sh_byte) '\0'; 283 bbuf[i+1] = (sh_byte) '\0'; 284 bbuf[i+2] = (sh_byte) '\0'; 285 bbuf[i+3] = (sh_byte) '\0'; 286 } 272 287 for (i = (count/64) * 64; i < count; ++i) 273 288 /*@-usedef@*/bbuf[j++] = buffer[i];/*@+usedef@*/ … … 304 319 sh.statistics.bytes_hashed += 64; 305 320 ++nblocks; ncount = 0; 306 memset(bbuf, 0, 56 ); 321 for (i = 0; i < 56; i += 4) 322 { 323 bbuf[i] = (sh_byte) '\0'; 324 bbuf[i+1] = (sh_byte) '\0'; 325 bbuf[i+2] = (sh_byte) '\0'; 326 bbuf[i+3] = (sh_byte) '\0'; 327 } 328 /* memset(bbuf, 0, 56 ); */ 307 329 } 308 330 … … 327 349 #endif 328 350 329 memset (bbuf, 0, 64); 330 memset (buffer, 0, PRIV_MAX); 331 332 (void) sh_unix_munlock( (char *) buffer, (PRIV_MAX) * sizeof(sh_byte)); 351 for (i = 0; i < 64; i += 4) 352 { 353 bbuf[i] = (sh_byte) '\0'; 354 bbuf[i+1] = (sh_byte) '\0'; 355 bbuf[i+2] = (sh_byte) '\0'; 356 bbuf[i+3] = (sh_byte) '\0'; 357 } 358 359 bptr = buffer; 360 361 memcpy(bptr, bbuf, 64); bptr += 64; 362 memcpy(bptr, bbuf, 64); bptr += 64; 363 memcpy(bptr, buffer, 128); bptr += 128; 364 memcpy(bptr, buffer, 256); bptr += 256; 365 memcpy(bptr, buffer, 512); bptr += 512; 366 memcpy(bptr, buffer,1024); bptr += 1024; 367 memcpy(bptr, buffer,2048); 333 368 334 369 if (what == TIGER_FILE) … … 343 378 if (what == TIGER_DATA && filename != NULL) 344 379 { 345 /* TPT((0, FIL__, __LINE__, _("msg=<TIGER_DATA>\n"))); */346 380 tiger(TIGER_CAST filename, (sh_word32) Length, res); 347 381 SL_RETURN(res, _("sh_tiger_hash_val")); … … 1158 1192 SL_TICKET fd; 1159 1193 char * tmp; 1160 uid_t 1194 uid_t euid; 1161 1195 1162 1196 unsigned long pages_read;
Note:
See TracChangeset
for help on using the changeset viewer.