core: avoid pthread dependency in mbedtls initialization

This commit is contained in:
Romain Thomas
2026-08-30 15:08:49 +02:00
parent 9a78a15cee
commit 811a871fdf
+4 -4
View File
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <mutex>
#include <cstdlib>
#include "logging.hpp"
#include "mbedtls_init.hpp"
@@ -31,13 +31,13 @@
namespace LIEF {
void mbedtls_init() {
static std::once_flag ONCE;
std::call_once(ONCE, [] {
[[maybe_unused]] static bool INITIALIZED = [] {
mbedtls_init_threading_alt();
if (psa_status_t status = psa_crypto_init(); status != PSA_SUCCESS) {
LIEF_WARN("psa_crypto_init() didn't succeed: {}", (int)status);
}
std::atexit(mbedtls_psa_crypto_free);
});
return true;
}();
}
}