| 167 | } |
| 168 | |
| 169 | static void initialize() { |
| 170 | g_instanceDic = new unordered_map<string, MMKV *>; |
| 171 | g_instanceLock = new ThreadLock(); |
| 172 | g_instanceLock->initialize(); |
| 173 | |
| 174 | mmkv::DEFAULT_MMAP_SIZE = mmkv::getPageSize(); |
| 175 | MMKVInfo("version %s, page size %d, arch %s", MMKV_VERSION, DEFAULT_MMAP_SIZE, MMKV_ABI); |
| 176 | |
| 177 | // get CPU status of ARMv8 extensions (CRC32, AES) |
| 178 | #if defined(__aarch64__) && defined(__linux__) && !defined (MMKV_OHOS) |
| 179 | auto hwcaps = getauxval(AT_HWCAP); |
| 180 | # ifndef MMKV_DISABLE_CRYPT |
| 181 | if (hwcaps & HWCAP_AES) { |
| 182 | openssl::AES_set_encrypt_key = openssl_aes_arm_set_encrypt_key; |
| 183 | openssl::AES_set_decrypt_key = openssl_aes_arm_set_decrypt_key; |
| 184 | openssl::AES_encrypt = openssl_aes_arm_encrypt; |
| 185 | openssl::AES_decrypt = openssl_aes_arm_decrypt; |
| 186 | MMKVInfo("armv8 AES instructions is supported"); |
| 187 | } else { |
| 188 | MMKVInfo("armv8 AES instructions is not supported"); |
| 189 | } |
| 190 | # endif // MMKV_DISABLE_CRYPT |
| 191 | # ifdef MMKV_USE_ARMV8_CRC32 |
| 192 | if (hwcaps & HWCAP_CRC32) { |
| 193 | CRC32 = mmkv::armv8_crc32; |
| 194 | MMKVInfo("armv8 CRC32 instructions is supported"); |
| 195 | } else { |
| 196 | MMKVInfo("armv8 CRC32 instructions is not supported"); |
| 197 | } |
| 198 | # endif // MMKV_USE_ARMV8_CRC32 |
| 199 | #endif // __aarch64__ && defined(__linux__) && !defined (MMKV_OHOS) |
| 200 | |
| 201 | #if defined(MMKV_DEBUG) && !defined(MMKV_DISABLE_CRYPT) |
| 202 | // AESCrypt::testAESCrypt(); |
| 203 | // KeyValueHolderCrypt::testAESToMMBuffer(); |
| 204 | #endif |
| 205 | } |
| 206 | |
| 207 | static void ensureMinimalInitialize() { |
| 208 | static ThreadOnceToken_t once_control = ThreadOnceUninitialized; |
no test coverage detected