]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/crypto/isa-l/isa-l_crypto/md5_mb/md5_mb_vs_ossl_perf.c
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / crypto / isa-l / isa-l_crypto / md5_mb / md5_mb_vs_ossl_perf.c
index 7e9acde28b361c803f9b97963d4312fa36b4623f..0ba50a1d2b2961eabae1f4ce8a0259274eec91cc 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.
@@ -56,6 +56,7 @@ static uint8_t digest_ssl[TEST_BUFS][4 * MD5_DIGEST_NWORDS];
 
 int main(void)
 {
+       int ret;
        MD5_HASH_CTX_MGR *mgr = NULL;
        MD5_HASH_CTX ctxpool[TEST_BUFS];
        unsigned char *bufs[TEST_BUFS];
@@ -63,7 +64,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;
@@ -73,7 +74,11 @@ int main(void)
                ctxpool[i].user_data = (void *)((uint64_t) i);
        }
 
-       posix_memalign((void *)&mgr, 16, sizeof(MD5_HASH_CTX_MGR));
+       ret = posix_memalign((void *)&mgr, 16, sizeof(MD5_HASH_CTX_MGR));
+       if (ret) {
+               printf("alloc error: Fail");
+               return -1;
+       }
        md5_ctx_mgr_init(mgr);
 
        // Start OpenSSL tests
@@ -102,11 +107,12 @@ int main(void)
 
        for (i = 0; i < TEST_BUFS; i++) {
                for (j = 0; j < MD5_DIGEST_NWORDS; j++) {
-                       if (ctxpool[i].job.result_digest[j] != ((uint32_t *) digest_ssl[i])[j]) {
+                       if (ctxpool[i].job.result_digest[j] !=
+                           to_le32(((uint32_t *) digest_ssl[i])[j])) {
                                fail++;
                                printf("Test%d, digest%d fail %08X <=> %08X\n",
                                       i, j, ctxpool[i].job.result_digest[j],
-                                      ((uint32_t *) digest_ssl[i])[j]);
+                                      to_le32(((uint32_t *) digest_ssl[i])[j]));
                        }
                }
        }