Changeset 94404 in vbox for trunk/src/libs/openssl-3.0.2/crypto/lhash
- Timestamp:
- Mar 31, 2022 9:00:36 AM (3 years ago)
- Location:
- trunk/src/libs/openssl-3.0.2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/openssl-3.0.2
- Property svn:mergeinfo
-
old new 13 13 /vendor/openssl/1.1.1k:145841-145843 14 14 /vendor/openssl/3.0.1:150323-150324 15 /vendor/openssl/current:147554-150322 15 /vendor/openssl/3.0.2:150728-150729 16 /vendor/openssl/current:147554-150727
-
- Property svn:mergeinfo
-
trunk/src/libs/openssl-3.0.2/crypto/lhash/lh_stats.c
r94082 r94404 1 1 /* 2 * Copyright 1995-20 17The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 4 * Licensed under the Apache License 2.0 (the "License"). You may not use … … 62 62 void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out) 63 63 { 64 int omit_tsan = 0; 65 66 #ifdef TSAN_REQUIRES_LOCKING 67 if (!CRYPTO_THREAD_read_lock(lh->tsan_lock)) { 68 BIO_printf(out, "unable to lock table, omitting TSAN counters\n"); 69 omit_tsan = 1; 70 } 71 #endif 64 72 BIO_printf(out, "num_items = %lu\n", lh->num_items); 65 73 BIO_printf(out, "num_nodes = %u\n", lh->num_nodes); … … 69 77 BIO_printf(out, "num_contracts = %lu\n", lh->num_contracts); 70 78 BIO_printf(out, "num_contract_reallocs = %lu\n", lh->num_contract_reallocs); 71 BIO_printf(out, "num_hash_calls = %lu\n", lh->num_hash_calls); 72 BIO_printf(out, "num_comp_calls = %lu\n", lh->num_comp_calls); 79 if (!omit_tsan) { 80 BIO_printf(out, "num_hash_calls = %lu\n", lh->num_hash_calls); 81 BIO_printf(out, "num_comp_calls = %lu\n", lh->num_comp_calls); 82 } 73 83 BIO_printf(out, "num_insert = %lu\n", lh->num_insert); 74 84 BIO_printf(out, "num_replace = %lu\n", lh->num_replace); 75 85 BIO_printf(out, "num_delete = %lu\n", lh->num_delete); 76 86 BIO_printf(out, "num_no_delete = %lu\n", lh->num_no_delete); 77 BIO_printf(out, "num_retrieve = %lu\n", lh->num_retrieve); 78 BIO_printf(out, "num_retrieve_miss = %lu\n", lh->num_retrieve_miss); 79 BIO_printf(out, "num_hash_comps = %lu\n", lh->num_hash_comps); 87 if (!omit_tsan) { 88 BIO_printf(out, "num_retrieve = %lu\n", lh->num_retrieve); 89 BIO_printf(out, "num_retrieve_miss = %lu\n", lh->num_retrieve_miss); 90 BIO_printf(out, "num_hash_comps = %lu\n", lh->num_hash_comps); 91 #ifdef TSAN_REQUIRES_LOCKING 92 CRYPTO_THREAD_unlock(lh->tsan_lock); 93 #endif 94 } 80 95 } 81 96 -
trunk/src/libs/openssl-3.0.2/crypto/lhash/lhash.c
r94082 r94404 1 1 /* 2 * Copyright 1995-202 1The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 4 * Licensed under the Apache License 2.0 (the "License"). You may not use … … 45 45 static OPENSSL_LH_NODE **getrn(OPENSSL_LHASH *lh, const void *data, unsigned long *rhash); 46 46 47 static ossl_inline int tsan_lock(const OPENSSL_LHASH *lh) 48 { 49 #ifdef TSAN_REQUIRES_LOCKING 50 if (!CRYPTO_THREAD_write_lock(lh->tsan_lock)) 51 return 0; 52 #endif 53 return 1; 54 } 55 56 static ossl_inline void tsan_unlock(const OPENSSL_LHASH *lh) 57 { 58 #ifdef TSAN_REQUIRES_LOCKING 59 CRYPTO_THREAD_unlock(lh->tsan_lock); 60 #endif 61 } 62 47 63 OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c) 48 64 { … … 59 75 if ((ret->b = OPENSSL_zalloc(sizeof(*ret->b) * MIN_NODES)) == NULL) 60 76 goto err; 77 #ifdef TSAN_REQUIRES_LOCKING 78 if ((ret->tsan_lock = CRYPTO_THREAD_lock_new()) == NULL) 79 goto err; 80 #endif 61 81 ret->comp = ((c == NULL) ? (OPENSSL_LH_COMPFUNC)strcmp : c); 62 82 ret->hash = ((h == NULL) ? (OPENSSL_LH_HASHFUNC)OPENSSL_LH_strhash : h); … … 80 100 81 101 OPENSSL_LH_flush(lh); 102 #ifdef TSAN_REQUIRES_LOCKING 103 CRYPTO_THREAD_lock_free(lh->tsan_lock); 104 #endif 82 105 OPENSSL_free(lh->b); 83 106 OPENSSL_free(lh); … … 167 190 unsigned long hash; 168 191 OPENSSL_LH_NODE **rn; 169 void *ret; 170 192 193 /*- 194 * This should be atomic without tsan. 195 * It's not clear why it was done this way and not elsewhere. 196 */ 171 197 tsan_store((TSAN_QUALIFIER int *)&lh->error, 0); 172 198 173 199 rn = getrn(lh, data, &hash); 174 200 175 if (*rn == NULL) { 176 tsan_counter(&lh->num_retrieve_miss); 177 return NULL; 178 } else { 179 ret = (*rn)->data; 180 tsan_counter(&lh->num_retrieve); 181 } 182 183 return ret; 201 if (tsan_lock(lh)) { 202 tsan_counter(*rn == NULL ? &lh->num_retrieve_miss : &lh->num_retrieve); 203 tsan_unlock(lh); 204 } 205 return *rn == NULL ? NULL : (*rn)->data; 184 206 } 185 207 … … 308 330 unsigned long hash, nn; 309 331 OPENSSL_LH_COMPFUNC cf; 310 332 int do_tsan = 1; 333 334 #ifdef TSAN_REQUIRES_LOCKING 335 do_tsan = tsan_lock(lh); 336 #endif 311 337 hash = (*(lh->hash)) (data); 312 tsan_counter(&lh->num_hash_calls); 338 if (do_tsan) 339 tsan_counter(&lh->num_hash_calls); 313 340 *rhash = hash; 314 341 … … 320 347 ret = &(lh->b[(int)nn]); 321 348 for (n1 = *ret; n1 != NULL; n1 = n1->next) { 322 tsan_counter(&lh->num_hash_comps); 349 if (do_tsan) 350 tsan_counter(&lh->num_hash_comps); 323 351 if (n1->hash != hash) { 324 352 ret = &(n1->next); 325 353 continue; 326 354 } 327 tsan_counter(&lh->num_comp_calls); 355 if (do_tsan) 356 tsan_counter(&lh->num_comp_calls); 328 357 if (cf(n1->data, data) == 0) 329 358 break; 330 359 ret = &(n1->next); 331 360 } 361 if (do_tsan) 362 tsan_unlock(lh); 332 363 return ret; 333 364 } … … 353 384 n += 0x100; 354 385 r = (int)((v >> 2) ^ v) & 0x0f; 355 ret = (ret << r) | (ret >> (32 - r)); 386 /* cast to uint64_t to avoid 32 bit shift of 32 bit value */ 387 ret = (ret << r) | (unsigned long)((uint64_t)ret >> (32 - r)); 356 388 ret &= 0xFFFFFFFFL; 357 389 ret ^= v * v; … … 374 406 v = n | ossl_tolower(*c); 375 407 r = (int)((v >> 2) ^ v) & 0x0f; 376 ret = (ret << r) | (ret >> (32 - r)); 408 /* cast to uint64_t to avoid 32 bit shift of 32 bit value */ 409 ret = (ret << r) | (unsigned long)((uint64_t)ret >> (32 - r)); 377 410 ret &= 0xFFFFFFFFL; 378 411 ret ^= v * v; -
trunk/src/libs/openssl-3.0.2/crypto/lhash/lhash_local.h
r94082 r94404 1 1 /* 2 * Copyright 1995-20 18The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 4 * Licensed under the Apache License 2.0 (the "License"). You may not use … … 42 42 TSAN_QUALIFIER unsigned long num_hash_comps; 43 43 int error; 44 #ifdef TSAN_REQUIRES_LOCKING 45 CRYPTO_RWLOCK *tsan_lock; 46 #endif 44 47 };
Note:
See TracChangeset
for help on using the changeset viewer.