/src/openssl/include/internal/refcount.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the Apache License 2.0 (the "License"). You may not use |
5 | | * this file except in compliance with the License. You can obtain a copy |
6 | | * in the file LICENSE in the source distribution or at |
7 | | * https://www.openssl.org/source/license.html |
8 | | */ |
9 | | #ifndef OSSL_INTERNAL_REFCOUNT_H |
10 | | # define OSSL_INTERNAL_REFCOUNT_H |
11 | | |
12 | | /* Used to checking reference counts, most while doing perl5 stuff :-) */ |
13 | | # if defined(OPENSSL_NO_STDIO) |
14 | | # if defined(REF_PRINT) |
15 | | # error "REF_PRINT requires stdio" |
16 | | # endif |
17 | | # endif |
18 | | |
19 | | # ifndef OPENSSL_DEV_NO_ATOMICS |
20 | | # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ |
21 | | && !defined(__STDC_NO_ATOMICS__) |
22 | | # include <stdatomic.h> |
23 | | # define HAVE_C11_ATOMICS |
24 | | # endif |
25 | | |
26 | | # if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \ |
27 | | && ATOMIC_INT_LOCK_FREE > 0 |
28 | | |
29 | | # define HAVE_ATOMICS 1 |
30 | | |
31 | | typedef _Atomic int CRYPTO_REF_COUNT; |
32 | | |
33 | | static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock) |
34 | 0 | { |
35 | 0 | *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1; |
36 | 0 | return 1; |
37 | 0 | } Unexecuted instantiation: bio_lib.c:CRYPTO_UP_REF Unexecuted instantiation: bio_meth.c:CRYPTO_UP_REF Unexecuted instantiation: bss_null.c:CRYPTO_UP_REF Unexecuted instantiation: init.c:CRYPTO_UP_REF Unexecuted instantiation: v3_utl.c:CRYPTO_UP_REF Unexecuted instantiation: x509_cmp.c:CRYPTO_UP_REF Unexecuted instantiation: x509_ext.c:CRYPTO_UP_REF Unexecuted instantiation: x509_obj.c:CRYPTO_UP_REF Unexecuted instantiation: x509_req.c:CRYPTO_UP_REF Unexecuted instantiation: x509_set.c:CRYPTO_UP_REF Unexecuted instantiation: x509_v3.c:CRYPTO_UP_REF Unexecuted instantiation: x509name.c:CRYPTO_UP_REF Unexecuted instantiation: x509rset.c:CRYPTO_UP_REF Unexecuted instantiation: x_all.c:CRYPTO_UP_REF Unexecuted instantiation: x_crl.c:CRYPTO_UP_REF Unexecuted instantiation: x_exten.c:CRYPTO_UP_REF Unexecuted instantiation: x_name.c:CRYPTO_UP_REF Unexecuted instantiation: x_pubkey.c:CRYPTO_UP_REF Unexecuted instantiation: x_req.c:CRYPTO_UP_REF Unexecuted instantiation: x_x509.c:CRYPTO_UP_REF Unexecuted instantiation: x_x509a.c:CRYPTO_UP_REF Unexecuted instantiation: a_sign.c:CRYPTO_UP_REF Unexecuted instantiation: a_verify.c:CRYPTO_UP_REF Unexecuted instantiation: ameth_lib.c:CRYPTO_UP_REF Unexecuted instantiation: d2i_pr.c:CRYPTO_UP_REF Unexecuted instantiation: i2d_pr.c:CRYPTO_UP_REF Unexecuted instantiation: p8_pkey.c:CRYPTO_UP_REF Unexecuted instantiation: tasn_utl.c:CRYPTO_UP_REF Unexecuted instantiation: x_algor.c:CRYPTO_UP_REF Unexecuted instantiation: x_sig.c:CRYPTO_UP_REF Unexecuted instantiation: b_addr.c:CRYPTO_UP_REF Unexecuted instantiation: b_dump.c:CRYPTO_UP_REF Unexecuted instantiation: b_sock.c:CRYPTO_UP_REF Unexecuted instantiation: b_sock2.c:CRYPTO_UP_REF Unexecuted instantiation: bf_prefix.c:CRYPTO_UP_REF Unexecuted instantiation: bss_file.c:CRYPTO_UP_REF Unexecuted instantiation: bss_mem.c:CRYPTO_UP_REF Unexecuted instantiation: bss_sock.c:CRYPTO_UP_REF Unexecuted instantiation: dh_ameth.c:CRYPTO_UP_REF Unexecuted instantiation: dh_asn1.c:CRYPTO_UP_REF Unexecuted instantiation: dh_check.c:CRYPTO_UP_REF Unexecuted instantiation: dh_key.c:CRYPTO_UP_REF Unexecuted instantiation: dh_lib.c:CRYPTO_UP_REF Unexecuted instantiation: dsa_ameth.c:CRYPTO_UP_REF Unexecuted instantiation: dsa_asn1.c:CRYPTO_UP_REF Unexecuted instantiation: dsa_lib.c:CRYPTO_UP_REF Unexecuted instantiation: dsa_ossl.c:CRYPTO_UP_REF Unexecuted instantiation: dsa_sign.c:CRYPTO_UP_REF Unexecuted instantiation: dsa_vrf.c:CRYPTO_UP_REF Unexecuted instantiation: dso_lib.c:CRYPTO_UP_REF Unexecuted instantiation: ec_ameth.c:CRYPTO_UP_REF Unexecuted instantiation: ec_asn1.c:CRYPTO_UP_REF Unexecuted instantiation: ec_check.c:CRYPTO_UP_REF Unexecuted instantiation: ec_curve.c:CRYPTO_UP_REF Unexecuted instantiation: ec_cvt.c:CRYPTO_UP_REF Unexecuted instantiation: ec_key.c:CRYPTO_UP_REF Unexecuted instantiation: ec_kmeth.c:CRYPTO_UP_REF Unexecuted instantiation: ec_lib.c:CRYPTO_UP_REF Unexecuted instantiation: ec_mult.c:CRYPTO_UP_REF Unexecuted instantiation: ec_oct.c:CRYPTO_UP_REF Unexecuted instantiation: ecdh_ossl.c:CRYPTO_UP_REF Unexecuted instantiation: ecdsa_ossl.c:CRYPTO_UP_REF Unexecuted instantiation: ecdsa_sign.c:CRYPTO_UP_REF Unexecuted instantiation: ecdsa_vrf.c:CRYPTO_UP_REF Unexecuted instantiation: ecp_mont.c:CRYPTO_UP_REF Unexecuted instantiation: ecp_nistp224.c:CRYPTO_UP_REF Unexecuted instantiation: ecp_nistp256.c:CRYPTO_UP_REF Unexecuted instantiation: ecp_nistp521.c:CRYPTO_UP_REF Unexecuted instantiation: ecp_nistputil.c:CRYPTO_UP_REF Unexecuted instantiation: ecp_nistz256.c:CRYPTO_UP_REF Unexecuted instantiation: ecp_oct.c:CRYPTO_UP_REF Unexecuted instantiation: ecp_smpl.c:CRYPTO_UP_REF Unexecuted instantiation: ecx_meth.c:CRYPTO_UP_REF Unexecuted instantiation: eng_all.c:CRYPTO_UP_REF Unexecuted instantiation: eng_dyn.c:CRYPTO_UP_REF Unexecuted instantiation: eng_fat.c:CRYPTO_UP_REF Unexecuted instantiation: eng_init.c:CRYPTO_UP_REF Unexecuted instantiation: eng_lib.c:CRYPTO_UP_REF Unexecuted instantiation: eng_list.c:CRYPTO_UP_REF Unexecuted instantiation: eng_pkey.c:CRYPTO_UP_REF Unexecuted instantiation: tb_asnmth.c:CRYPTO_UP_REF Unexecuted instantiation: tb_cipher.c:CRYPTO_UP_REF Unexecuted instantiation: tb_dh.c:CRYPTO_UP_REF Unexecuted instantiation: tb_digest.c:CRYPTO_UP_REF Unexecuted instantiation: tb_dsa.c:CRYPTO_UP_REF Unexecuted instantiation: tb_eckey.c:CRYPTO_UP_REF Unexecuted instantiation: tb_pkmeth.c:CRYPTO_UP_REF Unexecuted instantiation: tb_rand.c:CRYPTO_UP_REF Unexecuted instantiation: tb_rsa.c:CRYPTO_UP_REF Unexecuted instantiation: c_allc.c:CRYPTO_UP_REF Unexecuted instantiation: c_alld.c:CRYPTO_UP_REF Unexecuted instantiation: cmeth_lib.c:CRYPTO_UP_REF Unexecuted instantiation: digest.c:CRYPTO_UP_REF Unexecuted instantiation: e_aes.c:CRYPTO_UP_REF Unexecuted instantiation: e_aes_cbc_hmac_sha1.c:CRYPTO_UP_REF Unexecuted instantiation: e_aes_cbc_hmac_sha256.c:CRYPTO_UP_REF Unexecuted instantiation: e_aria.c:CRYPTO_UP_REF Unexecuted instantiation: e_bf.c:CRYPTO_UP_REF Unexecuted instantiation: e_camellia.c:CRYPTO_UP_REF Unexecuted instantiation: e_cast.c:CRYPTO_UP_REF Unexecuted instantiation: e_chacha20_poly1305.c:CRYPTO_UP_REF Unexecuted instantiation: e_des.c:CRYPTO_UP_REF Unexecuted instantiation: e_des3.c:CRYPTO_UP_REF Unexecuted instantiation: e_idea.c:CRYPTO_UP_REF Unexecuted instantiation: e_rc2.c:CRYPTO_UP_REF Unexecuted instantiation: e_rc4.c:CRYPTO_UP_REF Unexecuted instantiation: e_rc4_hmac_md5.c:CRYPTO_UP_REF Unexecuted instantiation: e_rc5.c:CRYPTO_UP_REF Unexecuted instantiation: e_seed.c:CRYPTO_UP_REF Unexecuted instantiation: e_sm4.c:CRYPTO_UP_REF Unexecuted instantiation: e_xcbc_d.c:CRYPTO_UP_REF Unexecuted instantiation: evp_enc.c:CRYPTO_UP_REF Unexecuted instantiation: evp_fetch.c:CRYPTO_UP_REF Unexecuted instantiation: evp_lib.c:CRYPTO_UP_REF Unexecuted instantiation: evp_pkey.c:CRYPTO_UP_REF Unexecuted instantiation: evp_utils.c:CRYPTO_UP_REF Unexecuted instantiation: exchange.c:CRYPTO_UP_REF Unexecuted instantiation: keymgmt_lib.c:CRYPTO_UP_REF Unexecuted instantiation: keymgmt_meth.c:CRYPTO_UP_REF Unexecuted instantiation: legacy_blake2.c:CRYPTO_UP_REF Unexecuted instantiation: legacy_md4.c:CRYPTO_UP_REF Unexecuted instantiation: legacy_md5.c:CRYPTO_UP_REF Unexecuted instantiation: legacy_md5_sha1.c:CRYPTO_UP_REF Unexecuted instantiation: legacy_mdc2.c:CRYPTO_UP_REF Unexecuted instantiation: legacy_ripemd.c:CRYPTO_UP_REF Unexecuted instantiation: legacy_sha.c:CRYPTO_UP_REF Unexecuted instantiation: legacy_wp.c:CRYPTO_UP_REF Unexecuted instantiation: m_null.c:CRYPTO_UP_REF Unexecuted instantiation: m_sigver.c:CRYPTO_UP_REF Unexecuted instantiation: mac_lib.c:CRYPTO_UP_REF Unexecuted instantiation: mac_meth.c:CRYPTO_UP_REF Unexecuted instantiation: names.c:CRYPTO_UP_REF Unexecuted instantiation: p_lib.c:CRYPTO_UP_REF Unexecuted instantiation: p_sign.c:CRYPTO_UP_REF Unexecuted instantiation: p_verify.c:CRYPTO_UP_REF Unexecuted instantiation: pmeth_lib.c:CRYPTO_UP_REF Unexecuted instantiation: signature.c:CRYPTO_UP_REF Unexecuted instantiation: hm_ameth.c:CRYPTO_UP_REF Unexecuted instantiation: provider_core.c:CRYPTO_UP_REF Unexecuted instantiation: pem_pkey.c:CRYPTO_UP_REF Unexecuted instantiation: pk7_lib.c:CRYPTO_UP_REF Unexecuted instantiation: poly1305_ameth.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_ameth.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_asn1.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_chk.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_crpt.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_lib.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_mp.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_ossl.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_pmeth.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_pss.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_sign.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_sp800_56b_check.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_sp800_56b_gen.c:CRYPTO_UP_REF Unexecuted instantiation: serializer_lib.c:CRYPTO_UP_REF Unexecuted instantiation: serializer_meth.c:CRYPTO_UP_REF Unexecuted instantiation: serializer_pkey.c:CRYPTO_UP_REF Unexecuted instantiation: siphash_ameth.c:CRYPTO_UP_REF Unexecuted instantiation: sm2_pmeth.c:CRYPTO_UP_REF Unexecuted instantiation: legacy_sm3.c:CRYPTO_UP_REF Unexecuted instantiation: pcy_cache.c:CRYPTO_UP_REF Unexecuted instantiation: pcy_map.c:CRYPTO_UP_REF Unexecuted instantiation: v3_addr.c:CRYPTO_UP_REF Unexecuted instantiation: v3_asid.c:CRYPTO_UP_REF Unexecuted instantiation: v3_crld.c:CRYPTO_UP_REF Unexecuted instantiation: v3_ncons.c:CRYPTO_UP_REF Unexecuted instantiation: v3_purp.c:CRYPTO_UP_REF Unexecuted instantiation: v3_skey.c:CRYPTO_UP_REF Unexecuted instantiation: x509_att.c:CRYPTO_UP_REF Unexecuted instantiation: x509_lu.c:CRYPTO_UP_REF Unexecuted instantiation: x509_vfy.c:CRYPTO_UP_REF Unexecuted instantiation: x509_vpm.c:CRYPTO_UP_REF Unexecuted instantiation: x509cset.c:CRYPTO_UP_REF Unexecuted instantiation: x_attrib.c:CRYPTO_UP_REF Unexecuted instantiation: cipher_aes_cbc_hmac_sha1_hw.c:CRYPTO_UP_REF Unexecuted instantiation: cipher_aes_cbc_hmac_sha256_hw.c:CRYPTO_UP_REF Unexecuted instantiation: cipher_tdes_wrap.c:CRYPTO_UP_REF Unexecuted instantiation: hkdf.c:CRYPTO_UP_REF Unexecuted instantiation: kbkdf.c:CRYPTO_UP_REF Unexecuted instantiation: krb5kdf.c:CRYPTO_UP_REF Unexecuted instantiation: pbkdf2.c:CRYPTO_UP_REF Unexecuted instantiation: scrypt.c:CRYPTO_UP_REF Unexecuted instantiation: sshkdf.c:CRYPTO_UP_REF Unexecuted instantiation: sskdf.c:CRYPTO_UP_REF Unexecuted instantiation: tls1_prf.c:CRYPTO_UP_REF Unexecuted instantiation: x942kdf.c:CRYPTO_UP_REF Unexecuted instantiation: bf_buff.c:CRYPTO_UP_REF Unexecuted instantiation: cms_env.c:CRYPTO_UP_REF Unexecuted instantiation: cms_sd.c:CRYPTO_UP_REF Unexecuted instantiation: dh_group_params.c:CRYPTO_UP_REF Unexecuted instantiation: dh_pmeth.c:CRYPTO_UP_REF Unexecuted instantiation: dh_rfc5114.c:CRYPTO_UP_REF Unexecuted instantiation: dsa_pmeth.c:CRYPTO_UP_REF Unexecuted instantiation: dso_dlfcn.c:CRYPTO_UP_REF Unexecuted instantiation: curve25519.c:CRYPTO_UP_REF Unexecuted instantiation: ec2_oct.c:CRYPTO_UP_REF Unexecuted instantiation: ec2_smpl.c:CRYPTO_UP_REF Unexecuted instantiation: ec_pmeth.c:CRYPTO_UP_REF Unexecuted instantiation: ec_print.c:CRYPTO_UP_REF Unexecuted instantiation: ecdh_kdf.c:CRYPTO_UP_REF Unexecuted instantiation: ecp_nist.c:CRYPTO_UP_REF Unexecuted instantiation: eng_cnf.c:CRYPTO_UP_REF Unexecuted instantiation: eng_ctrl.c:CRYPTO_UP_REF Unexecuted instantiation: eng_table.c:CRYPTO_UP_REF Unexecuted instantiation: evp_pbe.c:CRYPTO_UP_REF Unexecuted instantiation: kdf_lib.c:CRYPTO_UP_REF Unexecuted instantiation: kdf_meth.c:CRYPTO_UP_REF Unexecuted instantiation: p5_crpt2.c:CRYPTO_UP_REF Unexecuted instantiation: pkey_kdf.c:CRYPTO_UP_REF Unexecuted instantiation: pkey_mac.c:CRYPTO_UP_REF Unexecuted instantiation: pmeth_fn.c:CRYPTO_UP_REF Unexecuted instantiation: pmeth_gn.c:CRYPTO_UP_REF Unexecuted instantiation: p12_p8e.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_gen.c:CRYPTO_UP_REF Unexecuted instantiation: rsa_oaep.c:CRYPTO_UP_REF Unexecuted instantiation: v3_conf.c:CRYPTO_UP_REF Unexecuted instantiation: x509_trs.c:CRYPTO_UP_REF Unexecuted instantiation: asn_mime.c:CRYPTO_UP_REF Unexecuted instantiation: dh_gen.c:CRYPTO_UP_REF Unexecuted instantiation: dsa_key.c:CRYPTO_UP_REF Unexecuted instantiation: encode.c:CRYPTO_UP_REF |
38 | | |
39 | | /* |
40 | | * Changes to shared structure other than reference counter have to be |
41 | | * serialized. And any kind of serialization implies a release fence. This |
42 | | * means that by the time reference counter is decremented all other |
43 | | * changes are visible on all processors. Hence decrement itself can be |
44 | | * relaxed. In case it hits zero, object will be destructed. Since it's |
45 | | * last use of the object, destructor programmer might reason that access |
46 | | * to mutable members doesn't have to be serialized anymore, which would |
47 | | * otherwise imply an acquire fence. Hence conditional acquire fence... |
48 | | */ |
49 | | static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock) |
50 | 335k | { |
51 | 335k | *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; |
52 | 335k | if (*ret == 0) |
53 | 332k | atomic_thread_fence(memory_order_acquire); |
54 | 335k | return 1; |
55 | 335k | } bio_lib.c:CRYPTO_DOWN_REF Line | Count | Source | 50 | 68.7k | { | 51 | 68.7k | *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; | 52 | 68.7k | if (*ret == 0) | 53 | 68.7k | atomic_thread_fence(memory_order_acquire); | 54 | 68.7k | return 1; | 55 | 68.7k | } |
Unexecuted instantiation: bio_meth.c:CRYPTO_DOWN_REF Unexecuted instantiation: bss_null.c:CRYPTO_DOWN_REF Unexecuted instantiation: init.c:CRYPTO_DOWN_REF Unexecuted instantiation: v3_utl.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_cmp.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_ext.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_obj.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_req.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_set.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_v3.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509name.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509rset.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_all.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_crl.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_exten.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_name.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_pubkey.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_req.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_x509.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_x509a.c:CRYPTO_DOWN_REF Unexecuted instantiation: a_sign.c:CRYPTO_DOWN_REF Unexecuted instantiation: a_verify.c:CRYPTO_DOWN_REF Unexecuted instantiation: ameth_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: d2i_pr.c:CRYPTO_DOWN_REF Unexecuted instantiation: i2d_pr.c:CRYPTO_DOWN_REF Unexecuted instantiation: p8_pkey.c:CRYPTO_DOWN_REF tasn_utl.c:CRYPTO_DOWN_REF Line | Count | Source | 50 | 91.0k | { | 51 | 91.0k | *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; | 52 | 91.0k | if (*ret == 0) | 53 | 91.0k | atomic_thread_fence(memory_order_acquire); | 54 | 91.0k | return 1; | 55 | 91.0k | } |
Unexecuted instantiation: x_algor.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_sig.c:CRYPTO_DOWN_REF Unexecuted instantiation: b_addr.c:CRYPTO_DOWN_REF Unexecuted instantiation: b_dump.c:CRYPTO_DOWN_REF Unexecuted instantiation: b_sock.c:CRYPTO_DOWN_REF Unexecuted instantiation: b_sock2.c:CRYPTO_DOWN_REF Unexecuted instantiation: bf_prefix.c:CRYPTO_DOWN_REF Unexecuted instantiation: bss_file.c:CRYPTO_DOWN_REF Unexecuted instantiation: bss_mem.c:CRYPTO_DOWN_REF Unexecuted instantiation: bss_sock.c:CRYPTO_DOWN_REF Unexecuted instantiation: dh_ameth.c:CRYPTO_DOWN_REF Unexecuted instantiation: dh_asn1.c:CRYPTO_DOWN_REF Unexecuted instantiation: dh_check.c:CRYPTO_DOWN_REF Unexecuted instantiation: dh_key.c:CRYPTO_DOWN_REF Line | Count | Source | 50 | 1.77k | { | 51 | 1.77k | *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; | 52 | 1.77k | if (*ret == 0) | 53 | 1.77k | atomic_thread_fence(memory_order_acquire); | 54 | 1.77k | return 1; | 55 | 1.77k | } |
Unexecuted instantiation: dsa_ameth.c:CRYPTO_DOWN_REF Unexecuted instantiation: dsa_asn1.c:CRYPTO_DOWN_REF dsa_lib.c:CRYPTO_DOWN_REF Line | Count | Source | 50 | 1.95k | { | 51 | 1.95k | *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; | 52 | 1.95k | if (*ret == 0) | 53 | 1.95k | atomic_thread_fence(memory_order_acquire); | 54 | 1.95k | return 1; | 55 | 1.95k | } |
Unexecuted instantiation: dsa_ossl.c:CRYPTO_DOWN_REF Unexecuted instantiation: dsa_sign.c:CRYPTO_DOWN_REF Unexecuted instantiation: dsa_vrf.c:CRYPTO_DOWN_REF Unexecuted instantiation: dso_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_ameth.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_asn1.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_check.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_curve.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_cvt.c:CRYPTO_DOWN_REF Line | Count | Source | 50 | 32.6k | { | 51 | 32.6k | *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; | 52 | 32.6k | if (*ret == 0) | 53 | 32.6k | atomic_thread_fence(memory_order_acquire); | 54 | 32.6k | return 1; | 55 | 32.6k | } |
Unexecuted instantiation: ec_kmeth.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_mult.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_oct.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecdh_ossl.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecdsa_ossl.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecdsa_sign.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecdsa_vrf.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecp_mont.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecp_nistp224.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecp_nistp256.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecp_nistp521.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecp_nistputil.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecp_nistz256.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecp_oct.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecp_smpl.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecx_meth.c:CRYPTO_DOWN_REF Unexecuted instantiation: eng_all.c:CRYPTO_DOWN_REF Unexecuted instantiation: eng_dyn.c:CRYPTO_DOWN_REF Unexecuted instantiation: eng_fat.c:CRYPTO_DOWN_REF Unexecuted instantiation: eng_init.c:CRYPTO_DOWN_REF eng_lib.c:CRYPTO_DOWN_REF Line | Count | Source | 50 | 3.01k | { | 51 | 3.01k | *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; | 52 | 3.01k | if (*ret == 0) | 53 | 0 | atomic_thread_fence(memory_order_acquire); | 54 | 3.01k | return 1; | 55 | 3.01k | } |
Unexecuted instantiation: eng_list.c:CRYPTO_DOWN_REF Unexecuted instantiation: eng_pkey.c:CRYPTO_DOWN_REF Unexecuted instantiation: tb_asnmth.c:CRYPTO_DOWN_REF Unexecuted instantiation: tb_cipher.c:CRYPTO_DOWN_REF Unexecuted instantiation: tb_dh.c:CRYPTO_DOWN_REF Unexecuted instantiation: tb_digest.c:CRYPTO_DOWN_REF Unexecuted instantiation: tb_dsa.c:CRYPTO_DOWN_REF Unexecuted instantiation: tb_eckey.c:CRYPTO_DOWN_REF Unexecuted instantiation: tb_pkmeth.c:CRYPTO_DOWN_REF Unexecuted instantiation: tb_rand.c:CRYPTO_DOWN_REF Unexecuted instantiation: tb_rsa.c:CRYPTO_DOWN_REF Unexecuted instantiation: c_allc.c:CRYPTO_DOWN_REF Unexecuted instantiation: c_alld.c:CRYPTO_DOWN_REF Unexecuted instantiation: cmeth_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: digest.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_aes.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_aes_cbc_hmac_sha1.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_aes_cbc_hmac_sha256.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_aria.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_bf.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_camellia.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_cast.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_chacha20_poly1305.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_des.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_des3.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_idea.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_rc2.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_rc4.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_rc4_hmac_md5.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_rc5.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_seed.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_sm4.c:CRYPTO_DOWN_REF Unexecuted instantiation: e_xcbc_d.c:CRYPTO_DOWN_REF Unexecuted instantiation: evp_enc.c:CRYPTO_DOWN_REF Unexecuted instantiation: evp_fetch.c:CRYPTO_DOWN_REF Unexecuted instantiation: evp_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: evp_pkey.c:CRYPTO_DOWN_REF Unexecuted instantiation: evp_utils.c:CRYPTO_DOWN_REF Unexecuted instantiation: exchange.c:CRYPTO_DOWN_REF Unexecuted instantiation: keymgmt_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: keymgmt_meth.c:CRYPTO_DOWN_REF Unexecuted instantiation: legacy_blake2.c:CRYPTO_DOWN_REF Unexecuted instantiation: legacy_md4.c:CRYPTO_DOWN_REF Unexecuted instantiation: legacy_md5.c:CRYPTO_DOWN_REF Unexecuted instantiation: legacy_md5_sha1.c:CRYPTO_DOWN_REF Unexecuted instantiation: legacy_mdc2.c:CRYPTO_DOWN_REF Unexecuted instantiation: legacy_ripemd.c:CRYPTO_DOWN_REF Unexecuted instantiation: legacy_sha.c:CRYPTO_DOWN_REF Unexecuted instantiation: legacy_wp.c:CRYPTO_DOWN_REF Unexecuted instantiation: m_null.c:CRYPTO_DOWN_REF Unexecuted instantiation: m_sigver.c:CRYPTO_DOWN_REF Unexecuted instantiation: mac_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: mac_meth.c:CRYPTO_DOWN_REF Unexecuted instantiation: names.c:CRYPTO_DOWN_REF Line | Count | Source | 50 | 122k | { | 51 | 122k | *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; | 52 | 122k | if (*ret == 0) | 53 | 122k | atomic_thread_fence(memory_order_acquire); | 54 | 122k | return 1; | 55 | 122k | } |
Unexecuted instantiation: p_sign.c:CRYPTO_DOWN_REF Unexecuted instantiation: p_verify.c:CRYPTO_DOWN_REF Unexecuted instantiation: pmeth_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: signature.c:CRYPTO_DOWN_REF Unexecuted instantiation: hm_ameth.c:CRYPTO_DOWN_REF Unexecuted instantiation: provider_core.c:CRYPTO_DOWN_REF Unexecuted instantiation: pem_pkey.c:CRYPTO_DOWN_REF Unexecuted instantiation: pk7_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: poly1305_ameth.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_ameth.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_asn1.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_chk.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_crpt.c:CRYPTO_DOWN_REF rsa_lib.c:CRYPTO_DOWN_REF Line | Count | Source | 50 | 13.4k | { | 51 | 13.4k | *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1; | 52 | 13.4k | if (*ret == 0) | 53 | 13.4k | atomic_thread_fence(memory_order_acquire); | 54 | 13.4k | return 1; | 55 | 13.4k | } |
Unexecuted instantiation: rsa_mp.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_ossl.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_pmeth.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_pss.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_sign.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_sp800_56b_check.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_sp800_56b_gen.c:CRYPTO_DOWN_REF Unexecuted instantiation: serializer_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: serializer_meth.c:CRYPTO_DOWN_REF Unexecuted instantiation: serializer_pkey.c:CRYPTO_DOWN_REF Unexecuted instantiation: siphash_ameth.c:CRYPTO_DOWN_REF Unexecuted instantiation: sm2_pmeth.c:CRYPTO_DOWN_REF Unexecuted instantiation: legacy_sm3.c:CRYPTO_DOWN_REF Unexecuted instantiation: pcy_cache.c:CRYPTO_DOWN_REF Unexecuted instantiation: pcy_map.c:CRYPTO_DOWN_REF Unexecuted instantiation: v3_addr.c:CRYPTO_DOWN_REF Unexecuted instantiation: v3_asid.c:CRYPTO_DOWN_REF Unexecuted instantiation: v3_crld.c:CRYPTO_DOWN_REF Unexecuted instantiation: v3_ncons.c:CRYPTO_DOWN_REF Unexecuted instantiation: v3_purp.c:CRYPTO_DOWN_REF Unexecuted instantiation: v3_skey.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_att.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_lu.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_vfy.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_vpm.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509cset.c:CRYPTO_DOWN_REF Unexecuted instantiation: x_attrib.c:CRYPTO_DOWN_REF Unexecuted instantiation: cipher_aes_cbc_hmac_sha1_hw.c:CRYPTO_DOWN_REF Unexecuted instantiation: cipher_aes_cbc_hmac_sha256_hw.c:CRYPTO_DOWN_REF Unexecuted instantiation: cipher_tdes_wrap.c:CRYPTO_DOWN_REF Unexecuted instantiation: hkdf.c:CRYPTO_DOWN_REF Unexecuted instantiation: kbkdf.c:CRYPTO_DOWN_REF Unexecuted instantiation: krb5kdf.c:CRYPTO_DOWN_REF Unexecuted instantiation: pbkdf2.c:CRYPTO_DOWN_REF Unexecuted instantiation: scrypt.c:CRYPTO_DOWN_REF Unexecuted instantiation: sshkdf.c:CRYPTO_DOWN_REF Unexecuted instantiation: sskdf.c:CRYPTO_DOWN_REF Unexecuted instantiation: tls1_prf.c:CRYPTO_DOWN_REF Unexecuted instantiation: x942kdf.c:CRYPTO_DOWN_REF Unexecuted instantiation: bf_buff.c:CRYPTO_DOWN_REF Unexecuted instantiation: cms_env.c:CRYPTO_DOWN_REF Unexecuted instantiation: cms_sd.c:CRYPTO_DOWN_REF Unexecuted instantiation: dh_group_params.c:CRYPTO_DOWN_REF Unexecuted instantiation: dh_pmeth.c:CRYPTO_DOWN_REF Unexecuted instantiation: dh_rfc5114.c:CRYPTO_DOWN_REF Unexecuted instantiation: dsa_pmeth.c:CRYPTO_DOWN_REF Unexecuted instantiation: dso_dlfcn.c:CRYPTO_DOWN_REF Unexecuted instantiation: curve25519.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec2_oct.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec2_smpl.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_pmeth.c:CRYPTO_DOWN_REF Unexecuted instantiation: ec_print.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecdh_kdf.c:CRYPTO_DOWN_REF Unexecuted instantiation: ecp_nist.c:CRYPTO_DOWN_REF Unexecuted instantiation: eng_cnf.c:CRYPTO_DOWN_REF Unexecuted instantiation: eng_ctrl.c:CRYPTO_DOWN_REF Unexecuted instantiation: eng_table.c:CRYPTO_DOWN_REF Unexecuted instantiation: evp_pbe.c:CRYPTO_DOWN_REF Unexecuted instantiation: kdf_lib.c:CRYPTO_DOWN_REF Unexecuted instantiation: kdf_meth.c:CRYPTO_DOWN_REF Unexecuted instantiation: p5_crpt2.c:CRYPTO_DOWN_REF Unexecuted instantiation: pkey_kdf.c:CRYPTO_DOWN_REF Unexecuted instantiation: pkey_mac.c:CRYPTO_DOWN_REF Unexecuted instantiation: pmeth_fn.c:CRYPTO_DOWN_REF Unexecuted instantiation: pmeth_gn.c:CRYPTO_DOWN_REF Unexecuted instantiation: p12_p8e.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_gen.c:CRYPTO_DOWN_REF Unexecuted instantiation: rsa_oaep.c:CRYPTO_DOWN_REF Unexecuted instantiation: v3_conf.c:CRYPTO_DOWN_REF Unexecuted instantiation: x509_trs.c:CRYPTO_DOWN_REF Unexecuted instantiation: asn_mime.c:CRYPTO_DOWN_REF Unexecuted instantiation: dh_gen.c:CRYPTO_DOWN_REF Unexecuted instantiation: dsa_key.c:CRYPTO_DOWN_REF Unexecuted instantiation: encode.c:CRYPTO_DOWN_REF |
56 | | |
57 | | # elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0 |
58 | | |
59 | | # define HAVE_ATOMICS 1 |
60 | | |
61 | | typedef int CRYPTO_REF_COUNT; |
62 | | |
63 | | static __inline__ int CRYPTO_UP_REF(int *val, int *ret, void *lock) |
64 | | { |
65 | | *ret = __atomic_fetch_add(val, 1, __ATOMIC_RELAXED) + 1; |
66 | | return 1; |
67 | | } |
68 | | |
69 | | static __inline__ int CRYPTO_DOWN_REF(int *val, int *ret, void *lock) |
70 | | { |
71 | | *ret = __atomic_fetch_sub(val, 1, __ATOMIC_RELAXED) - 1; |
72 | | if (*ret == 0) |
73 | | __atomic_thread_fence(__ATOMIC_ACQUIRE); |
74 | | return 1; |
75 | | } |
76 | | # elif defined(__ICL) && defined(_WIN32) |
77 | | # define HAVE_ATOMICS 1 |
78 | | typedef volatile int CRYPTO_REF_COUNT; |
79 | | |
80 | | static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock) |
81 | | { |
82 | | *ret = _InterlockedExchangeAdd((void *)val, 1) + 1; |
83 | | return 1; |
84 | | } |
85 | | |
86 | | static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock) |
87 | | { |
88 | | *ret = _InterlockedExchangeAdd((void *)val, -1) - 1; |
89 | | return 1; |
90 | | } |
91 | | |
92 | | # elif defined(_MSC_VER) && _MSC_VER>=1200 |
93 | | |
94 | | # define HAVE_ATOMICS 1 |
95 | | |
96 | | typedef volatile int CRYPTO_REF_COUNT; |
97 | | |
98 | | # if (defined(_M_ARM) && _M_ARM>=7 && !defined(_WIN32_WCE)) || defined(_M_ARM64) |
99 | | # include <intrin.h> |
100 | | # if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH) |
101 | | # define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH |
102 | | # endif |
103 | | |
104 | | static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock) |
105 | | { |
106 | | *ret = _InterlockedExchangeAdd_nf(val, 1) + 1; |
107 | | return 1; |
108 | | } |
109 | | |
110 | | static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock) |
111 | | { |
112 | | *ret = _InterlockedExchangeAdd_nf(val, -1) - 1; |
113 | | if (*ret == 0) |
114 | | __dmb(_ARM_BARRIER_ISH); |
115 | | return 1; |
116 | | } |
117 | | # else |
118 | | # if !defined(_WIN32_WCE) |
119 | | # pragma intrinsic(_InterlockedExchangeAdd) |
120 | | # else |
121 | | # if _WIN32_WCE >= 0x600 |
122 | | extern long __cdecl _InterlockedExchangeAdd(long volatile*, long); |
123 | | # else |
124 | | /* under Windows CE we still have old-style Interlocked* functions */ |
125 | | extern long __cdecl InterlockedExchangeAdd(long volatile*, long); |
126 | | # define _InterlockedExchangeAdd InterlockedExchangeAdd |
127 | | # endif |
128 | | # endif |
129 | | |
130 | | static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock) |
131 | | { |
132 | | *ret = _InterlockedExchangeAdd(val, 1) + 1; |
133 | | return 1; |
134 | | } |
135 | | |
136 | | static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock) |
137 | | { |
138 | | *ret = _InterlockedExchangeAdd(val, -1) - 1; |
139 | | return 1; |
140 | | } |
141 | | # endif |
142 | | |
143 | | # endif |
144 | | # endif /* !OPENSSL_DEV_NO_ATOMICS */ |
145 | | |
146 | | /* |
147 | | * All the refcounting implementations above define HAVE_ATOMICS, so if it's |
148 | | * still undefined here (such as when OPENSSL_DEV_NO_ATMOICS is defined), it |
149 | | * means we need to implement a fallback. This fallback uses locks. |
150 | | */ |
151 | | # ifndef HAVE_ATOMICS |
152 | | |
153 | | typedef int CRYPTO_REF_COUNT; |
154 | | |
155 | | # define CRYPTO_UP_REF(val, ret, lock) CRYPTO_atomic_add(val, 1, ret, lock) |
156 | | # define CRYPTO_DOWN_REF(val, ret, lock) CRYPTO_atomic_add(val, -1, ret, lock) |
157 | | |
158 | | # endif |
159 | | |
160 | | # if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO) |
161 | | # define REF_ASSERT_ISNT(test) \ |
162 | 332k | (void)((test) ? (OPENSSL_die("refcount error", __FILE__, __LINE__), 1) : 0) |
163 | | # else |
164 | | # define REF_ASSERT_ISNT(i) |
165 | | # endif |
166 | | |
167 | | # ifdef REF_PRINT |
168 | | # define REF_PRINT_COUNT(a, b) \ |
169 | | fprintf(stderr, "%p:%4d:%s\n", b, b->references, a) |
170 | | # else |
171 | | # define REF_PRINT_COUNT(a, b) |
172 | | # endif |
173 | | |
174 | | #endif |