|
Lines 111-117
Link Here
|
| 111 |
#endif /* CRC32_ARM64 */ |
111 |
#endif /* CRC32_ARM64 */ |
| 112 |
|
112 |
|
| 113 |
#ifdef CRC32_ARM64_DEFAULT |
113 |
#ifdef CRC32_ARM64_DEFAULT |
|
|
114 |
#ifndef __FreeBSD__ |
| 114 |
#include <asm/hwcap.h> |
115 |
#include <asm/hwcap.h> |
|
|
116 |
#endif |
| 115 |
#include <sys/auxv.h> |
117 |
#include <sys/auxv.h> |
| 116 |
#endif /* CRC32_ARM64_DEFAULT */ |
118 |
#endif /* CRC32_ARM64_DEFAULT */ |
| 117 |
|
119 |
|
|
Lines 360-367
Link Here
|
| 360 |
#endif /* CRC32_ARM64_APPLE */ |
362 |
#endif /* CRC32_ARM64_APPLE */ |
| 361 |
|
363 |
|
| 362 |
#ifdef CRC32_ARM64_DEFAULT |
364 |
#ifdef CRC32_ARM64_DEFAULT |
|
|
365 |
#ifdef __FreeBSD__ |
| 366 |
bool can_use_crc32() { |
| 367 |
unsigned long capabilities; |
| 368 |
|
| 369 |
if (elf_aux_info(AT_HWCAP, &capabilities, sizeof(unsigned long))) |
| 370 |
return false; |
| 371 |
return capabilities & HWCAP_CRC32; |
| 372 |
} |
| 373 |
bool can_use_poly_mul() { |
| 374 |
unsigned long capabilities; |
| 375 |
|
| 376 |
if (elf_aux_info(AT_HWCAP, &capabilities, sizeof(unsigned long))) |
| 377 |
return false; |
| 378 |
return capabilities & HWCAP_CRC32; |
| 379 |
} |
| 380 |
#else |
| 363 |
bool can_use_crc32() { return getauxval(AT_HWCAP) & HWCAP_CRC32; } |
381 |
bool can_use_crc32() { return getauxval(AT_HWCAP) & HWCAP_CRC32; } |
| 364 |
bool can_use_poly_mul() { return getauxval(AT_HWCAP) & HWCAP_PMULL; } |
382 |
bool can_use_poly_mul() { return getauxval(AT_HWCAP) & HWCAP_PMULL; } |
|
|
383 |
#endif |
| 365 |
#endif /* CRC32_ARM64_DEFAULT */ |
384 |
#endif /* CRC32_ARM64_DEFAULT */ |
| 366 |
|
385 |
|
| 367 |
/** A helper template to statically unroll a loop with a fixed number of |
386 |
/** A helper template to statically unroll a loop with a fixed number of |
|
Lines 472-498
Link Here
|
| 472 |
#ifdef CRC32_ARM64_DEFAULT |
491 |
#ifdef CRC32_ARM64_DEFAULT |
| 473 |
MY_ATTRIBUTE((target("+crc"))) |
492 |
MY_ATTRIBUTE((target("+crc"))) |
| 474 |
#endif /* CRC32_ARM64_DEFAULT */ |
493 |
#endif /* CRC32_ARM64_DEFAULT */ |
|
|
494 |
#ifdef __FreeBSD__ |
| 495 |
#include <arm_acle.h> |
| 475 |
uint32_t crc32_impl::update(uint32_t crc, unsigned char data) { |
496 |
uint32_t crc32_impl::update(uint32_t crc, unsigned char data) { |
| 476 |
return __crc32cb(crc, data); |
497 |
__crc32cb(crc, data); |
|
|
498 |
return crc; |
| 477 |
} |
499 |
} |
|
|
500 |
uint32_t crc32_impl::update(uint32_t crc, uint16_t data) { |
| 501 |
__crc32ch(crc, data); |
| 502 |
return crc; |
| 503 |
} |
| 504 |
uint32_t crc32_impl::update(uint32_t crc, uint32_t data) { |
| 505 |
__crc32cw(crc, data); |
| 506 |
return crc; |
| 507 |
} |
| 508 |
uint64_t crc32_impl::update(uint64_t crc, uint64_t data) { |
| 509 |
__crc32cd(crc, data); |
| 510 |
return crc; |
| 511 |
} |
| 512 |
#else |
| 478 |
#ifdef CRC32_ARM64_DEFAULT |
513 |
#ifdef CRC32_ARM64_DEFAULT |
| 479 |
MY_ATTRIBUTE((target("+crc"))) |
514 |
MY_ATTRIBUTE((target("+crc"))) |
| 480 |
#endif /* CRC32_ARM64_DEFAULT */ |
515 |
#endif /* CRC32_ARM64_DEFAULT */ |
| 481 |
uint32_t crc32_impl::update(uint32_t crc, uint16_t data) { |
516 |
uint32_t crc32_impl::update(uint32_t crc, uint16_t data) { |
| 482 |
return __crc32ch(crc, data); |
517 |
__crc32ch(crc, data); |
|
|
518 |
return crc; |
| 483 |
} |
519 |
} |
| 484 |
#ifdef CRC32_ARM64_DEFAULT |
520 |
#ifdef CRC32_ARM64_DEFAULT |
| 485 |
MY_ATTRIBUTE((target("+crc"))) |
521 |
MY_ATTRIBUTE((target("+crc"))) |
| 486 |
#endif /* CRC32_ARM64_DEFAULT */ |
522 |
#endif /* CRC32_ARM64_DEFAULT */ |
| 487 |
uint32_t crc32_impl::update(uint32_t crc, uint32_t data) { |
523 |
uint32_t crc32_impl::update(uint32_t crc, uint32_t data) { |
| 488 |
return __crc32cw(crc, data); |
524 |
__crc32cw(crc, data); |
|
|
525 |
return crc; |
| 489 |
} |
526 |
} |
| 490 |
#ifdef CRC32_ARM64_DEFAULT |
527 |
#ifdef CRC32_ARM64_DEFAULT |
| 491 |
MY_ATTRIBUTE((target("+crc"))) |
528 |
MY_ATTRIBUTE((target("+crc"))) |
| 492 |
#endif /* CRC32_ARM64_DEFAULT */ |
529 |
#endif /* CRC32_ARM64_DEFAULT */ |
| 493 |
uint64_t crc32_impl::update(uint64_t crc, uint64_t data) { |
530 |
uint64_t crc32_impl::update(uint64_t crc, uint64_t data) { |
| 494 |
return (uint64_t)__crc32cd((uint32_t)crc, data); |
531 |
__crc32cd((uint32_t)crc, data); |
|
|
532 |
return crc; |
| 495 |
} |
533 |
} |
|
|
534 |
#endif |
| 496 |
#endif /* CRC32_ARM64 */ |
535 |
#endif /* CRC32_ARM64 */ |
| 497 |
|
536 |
|
| 498 |
/** Implementation of polynomial_mul_rev<w>(rev_u) function which uses hardware |
537 |
/** Implementation of polynomial_mul_rev<w>(rev_u) function which uses hardware |