]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/crypto/isa-l/isa-l_crypto/sha256_mb/sha256_mb_vs_ossl_perf.c
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / crypto / isa-l / isa-l_crypto / sha256_mb / sha256_mb_vs_ossl_perf.c
index 07184ae1939bea7aaf57840e473e4c3828d386db..51759d7a87a03bd5bedbc86ed6be31650c551112 100644 (file)
@@ -2,7 +2,7 @@
   Copyright(c) 2011-2016 Intel Corporation All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions 
+  modification, are permitted provided that the following conditions
   are met:
     * Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
 /* Reference digest global to reduce stack usage */
 static uint8_t digest_ssl[TEST_BUFS][4 * SHA256_DIGEST_NWORDS];
 
-inline unsigned int byteswap32(unsigned int x)
-{
-       return (x >> 24) | (x >> 8 & 0xff00) | (x << 8 & 0xff0000) | (x << 24);
-}
-
 int main(void)
 {
        SHA256_HASH_CTX_MGR *mgr = NULL;
@@ -68,7 +63,7 @@ int main(void)
        struct perf start, stop;
 
        for (i = 0; i < TEST_BUFS; i++) {
-               bufs[i] = (unsigned char *)calloc((size_t) TEST_LEN, 1);
+               bufs[i] = (unsigned char *)calloc((size_t)TEST_LEN, 1);
                if (bufs[i] == NULL) {
                        printf("calloc failed test aborted\n");
                        return 1;
@@ -78,7 +73,11 @@ int main(void)
                ctxpool[i].user_data = (void *)((uint64_t) i);
        }
 
-       posix_memalign((void *)&mgr, 16, sizeof(SHA256_HASH_CTX_MGR));
+       int ret = posix_memalign((void *)&mgr, 16, sizeof(SHA256_HASH_CTX_MGR));
+       if (ret) {
+               printf("alloc error: Fail");
+               return -1;
+       }
        sha256_ctx_mgr_init(mgr);
 
        // Start OpenSSL tests
@@ -109,11 +108,11 @@ int main(void)
        for (i = 0; i < TEST_BUFS; i++) {
                for (j = 0; j < SHA256_DIGEST_NWORDS; j++) {
                        if (ctxpool[i].job.result_digest[j] !=
-                           byteswap32(((uint32_t *) digest_ssl[i])[j])) {
+                           to_be32(((uint32_t *) digest_ssl[i])[j])) {
                                fail++;
                                printf("Test%d, digest%d fail %08X <=> %08X\n",
                                       i, j, ctxpool[i].job.result_digest[j],
-                                      byteswap32(((uint32_t *) digest_ssl[i])[j]));
+                                      to_be32(((uint32_t *) digest_ssl[i])[j]));
                        }
                }
        }