Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2012 Lawrence Livermore National Laboratory | 3 * Copyright (c) 2012 Lawrence Livermore National Laboratory |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 | 486 |
487 h1 += h2; | 487 h1 += h2; |
488 h2 += h1; | 488 h2 += h1; |
489 | 489 |
490 h1 = fmix(h1); | 490 h1 = fmix(h1); |
491 h2 = fmix(h2); | 491 h2 = fmix(h2); |
492 | 492 |
493 h1 += h2; | 493 h1 += h2; |
494 h2 += h1; | 494 h2 += h1; |
495 | 495 |
496 ((uint32_t *)out)[0] = (uint32_t)h1; | 496 ((uint32_t *)out)[0] = static_cast<uint32_t> (h1); //PDB cast |
497 ((uint32_t *)out)[1] = (uint32_t)h2; | 497 ((uint32_t *)out)[1] = static_cast<uint32_t> (h2); //PDB cast |
498 } | 498 } |
499 | 499 |
500 | 500 |
501 // End Murmur3.cpp -----------------------------> | 501 // End Murmur3.cpp -----------------------------> |
502 | 502 |
503 #undef BIG_CONSTANT | 503 #undef BIG_CONSTANT |
504 | 504 |
505 ·· | 505 ·· |
506 //----------------------------------------------------------------------------- | 506 //----------------------------------------------------------------------------- |
507 | 507 |
508 | 508 |
509 /**@}*/ // \defgroup hash_murmur3 | 509 /**@}*/ // \defgroup hash_murmur3 |
510 | 510 |
511 } // namespace Murmur3Implementation | 511 } // namespace Murmur3Implementation |
512 | 512 |
513 | 513 |
514 Murmur3::Murmur3 () | 514 Murmur3::Murmur3 () |
515 { | 515 { |
516 clear (); | 516 clear (); |
517 } | 517 } |
518 | 518 |
519 uint32_t | 519 uint32_t |
520 Murmur3::GetHash32 (const char * buffer, const size_t size) | 520 Murmur3::GetHash32 (const char * buffer, const size_t size) |
521 { | 521 { |
522 using namespace Murmur3Implementation; | 522 using namespace Murmur3Implementation; |
523 | 523 |
524 MurmurHash3_x86_32_incr (buffer, size, m_hash32, (void *) & m_hash32); | 524 MurmurHash3_x86_32_incr (buffer, static_cast<int> (size), |
525 m_size32 += size; | 525 m_hash32, (void *)& m_hash32); |
Peter Barnes
2018/05/11 21:58:11
Change size formal argument to size_t
ammo6818-vandals.uidaho.edu
2018/05/16 15:06:28
Done
| |
526 m_size32 += static_cast<uint32_t> (size); | |
Peter Barnes
2018/05/11 21:58:11
Change m_size32 type to size_t
ammo6818-vandals.uidaho.edu
2018/05/16 15:06:28
Done
| |
526 uint32_t hash; | 527 uint32_t hash; |
527 MurmurHash3_x86_32_fin (m_size32, m_hash32, (void *) & hash); | 528 MurmurHash3_x86_32_fin (m_size32, m_hash32, (void *) & hash); |
528 | 529 |
529 return hash; | 530 return hash; |
530 } | 531 } |
531 | 532 |
532 uint64_t | 533 uint64_t |
533 Murmur3::GetHash64 (const char * buffer, const size_t size) | 534 Murmur3::GetHash64 (const char * buffer, const size_t size) |
534 { | 535 { |
535 using namespace Murmur3Implementation; | 536 using namespace Murmur3Implementation; |
536 | 537 |
537 MurmurHash3_x86_128_incr (buffer, size, | 538 MurmurHash3_x86_128_incr (buffer, static_cast<int> (size), |
538 (uint32_t *)(void *)m_hash64, m_hash64); | 539 (uint32_t *)(void *)m_hash64, m_hash64); |
539 m_size64 += size; | 540 m_size64 += size; |
540 | 541 |
541 // Simpler would be: | 542 // Simpler would be: |
542 // | 543 // |
543 // uint64_t hash[2]; | 544 // uint64_t hash[2]; |
544 // MurmurHash3_x86_128_fin (m_size64, m_hash64, hash); | 545 // MurmurHash3_x86_128_fin (m_size64, m_hash64, hash); |
545 // return hash[0]; | 546 // return hash[0]; |
546 // | 547 // |
547 // but this triggers an aliasing bug in gcc-4.4 (perhaps related to | 548 // but this triggers an aliasing bug in gcc-4.4 (perhaps related to |
548 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39390). | 549 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39390). |
549 // In ns-3, this bug produces incorrect results in static optimized | 550 // In ns-3, this bug produces incorrect results in static optimized |
550 // builds only. | 551 // builds only. |
551 // | 552 // |
552 // Using uint32_t here avoids the bug, and continues to works with newer gcc. | 553 // Using uint32_t here avoids the bug, and continues to works with newer gcc. |
553 uint32_t hash[4]; | 554 uint32_t hash[4]; |
554 ·· | 555 ·· |
555 MurmurHash3_x86_128_fin ((int)m_size64, | 556 MurmurHash3_x86_128_fin (static_cast<int> (m_size64), |
Peter Barnes
2018/05/11 21:58:11
Change size formal argument to size_t
ammo6818-vandals.uidaho.edu
2018/05/16 15:06:28
Done
| |
556 (uint32_t *)(void *)m_hash64, hash); | 557 (uint32_t *)(void *)m_hash64, hash); |
557 uint64_t result = hash[1]; | 558 uint64_t result = hash[1]; |
558 result = (result << 32) | hash[0]; | 559 result = (result << 32) | hash[0]; |
559 return result; | 560 return result; |
560 } | 561 } |
561 | 562 |
562 void | 563 void |
563 Murmur3::clear (void) | 564 Murmur3::clear (void) |
564 { | 565 { |
565 m_hash32 = (uint32_t)SEED; | 566 m_hash32 = (uint32_t)SEED; |
566 m_size32 = 0; | 567 m_size32 = 0; |
567 m_hash64[0] = m_hash64[1] = ((uint64_t)SEED << 32) | (uint32_t)SEED; | 568 m_hash64[0] = m_hash64[1] = ((uint64_t)SEED << 32) | (uint32_t)SEED; |
568 m_size64 = 0; | 569 m_size64 = 0; |
569 } | 570 } |
570 | 571 |
571 } // namespace Function | 572 } // namespace Function |
572 | 573 |
573 } // namespace Hash | 574 } // namespace Hash |
574 | 575 |
575 } // namespace ns3 | 576 } // namespace ns3 |
LEFT | RIGHT |