react-native-mmkv 3.3.0 → 4.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/android/CMakeLists.txt +18 -9
  2. package/android/build.gradle +6 -2
  3. package/cpp/{MMKVManagedBuffer.h → ManagedMMBuffer.h} +6 -6
  4. package/cpp/MmkvHostObject.cpp +13 -8
  5. package/cpp/MmkvHostObject.h +1 -2
  6. package/cpp/MmkvTypes.h +50 -0
  7. package/cpp/NativeMmkvModule.cpp +3 -3
  8. package/cpp/NativeMmkvModule.h +1 -8
  9. package/package.json +22 -23
  10. package/react-native-mmkv.podspec +3 -9
  11. package/react-native.config.js +9 -0
  12. package/MMKV/Core/CMakeLists.txt +0 -172
  13. package/MMKV/Core/CodedInputData.cpp +0 -252
  14. package/MMKV/Core/CodedInputData.h +0 -87
  15. package/MMKV/Core/CodedInputDataCrypt.cpp +0 -280
  16. package/MMKV/Core/CodedInputDataCrypt.h +0 -87
  17. package/MMKV/Core/CodedInputDataCrypt_OSX.cpp +0 -62
  18. package/MMKV/Core/CodedInputData_OSX.cpp +0 -92
  19. package/MMKV/Core/CodedOutputData.cpp +0 -186
  20. package/MMKV/Core/CodedOutputData.h +0 -88
  21. package/MMKV/Core/Core.xcodeproj/project.pbxproj +0 -707
  22. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  23. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  24. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +0 -67
  25. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/MMKVWatchCore.xcscheme +0 -67
  26. package/MMKV/Core/InterProcessLock.cpp +0 -186
  27. package/MMKV/Core/InterProcessLock.h +0 -119
  28. package/MMKV/Core/InterProcessLock_Android.cpp +0 -103
  29. package/MMKV/Core/InterProcessLock_Win32.cpp +0 -108
  30. package/MMKV/Core/KeyValueHolder.cpp +0 -236
  31. package/MMKV/Core/KeyValueHolder.h +0 -122
  32. package/MMKV/Core/MMBuffer.cpp +0 -210
  33. package/MMKV/Core/MMBuffer.h +0 -111
  34. package/MMKV/Core/MMKV.cpp +0 -1702
  35. package/MMKV/Core/MMKV.h +0 -595
  36. package/MMKV/Core/MMKVLog.cpp +0 -127
  37. package/MMKV/Core/MMKVLog.h +0 -86
  38. package/MMKV/Core/MMKVLog_Android.cpp +0 -134
  39. package/MMKV/Core/MMKVMetaInfo.hpp +0 -99
  40. package/MMKV/Core/MMKVPredef.h +0 -293
  41. package/MMKV/Core/MMKV_Android.cpp +0 -261
  42. package/MMKV/Core/MMKV_IO.cpp +0 -1905
  43. package/MMKV/Core/MMKV_IO.h +0 -57
  44. package/MMKV/Core/MMKV_OSX.cpp +0 -423
  45. package/MMKV/Core/MMKV_OSX.h +0 -57
  46. package/MMKV/Core/MemoryFile.cpp +0 -603
  47. package/MMKV/Core/MemoryFile.h +0 -194
  48. package/MMKV/Core/MemoryFile_Android.cpp +0 -236
  49. package/MMKV/Core/MemoryFile_Linux.cpp +0 -125
  50. package/MMKV/Core/MemoryFile_OSX.cpp +0 -142
  51. package/MMKV/Core/MemoryFile_Win32.cpp +0 -554
  52. package/MMKV/Core/MiniPBCoder.cpp +0 -672
  53. package/MMKV/Core/MiniPBCoder.h +0 -151
  54. package/MMKV/Core/MiniPBCoder_OSX.cpp +0 -237
  55. package/MMKV/Core/PBEncodeItem.hpp +0 -104
  56. package/MMKV/Core/PBUtility.cpp +0 -61
  57. package/MMKV/Core/PBUtility.h +0 -148
  58. package/MMKV/Core/ScopedLock.hpp +0 -69
  59. package/MMKV/Core/ThreadLock.cpp +0 -75
  60. package/MMKV/Core/ThreadLock.h +0 -81
  61. package/MMKV/Core/ThreadLock_Win32.cpp +0 -89
  62. package/MMKV/Core/aes/AESCrypt.cpp +0 -273
  63. package/MMKV/Core/aes/AESCrypt.h +0 -112
  64. package/MMKV/Core/aes/openssl/openssl_aes-armv4.S +0 -1243
  65. package/MMKV/Core/aes/openssl/openssl_aes.h +0 -130
  66. package/MMKV/Core/aes/openssl/openssl_aes_core.cpp +0 -1044
  67. package/MMKV/Core/aes/openssl/openssl_aes_locl.h +0 -38
  68. package/MMKV/Core/aes/openssl/openssl_aesv8-armx.S +0 -308
  69. package/MMKV/Core/aes/openssl/openssl_arm_arch.h +0 -84
  70. package/MMKV/Core/aes/openssl/openssl_cfb128.cpp +0 -97
  71. package/MMKV/Core/aes/openssl/openssl_md32_common.h +0 -254
  72. package/MMKV/Core/aes/openssl/openssl_md5.h +0 -49
  73. package/MMKV/Core/aes/openssl/openssl_md5_dgst.cpp +0 -166
  74. package/MMKV/Core/aes/openssl/openssl_md5_locl.h +0 -75
  75. package/MMKV/Core/aes/openssl/openssl_md5_one.cpp +0 -30
  76. package/MMKV/Core/aes/openssl/openssl_opensslconf.h +0 -271
  77. package/MMKV/Core/core.vcxproj +0 -288
  78. package/MMKV/Core/core.vcxproj.filters +0 -150
  79. package/MMKV/Core/crc32/Checksum.h +0 -75
  80. package/MMKV/Core/crc32/crc32_armv8.cpp +0 -134
  81. package/MMKV/Core/crc32/zlib/CMakeLists.txt +0 -60
  82. package/MMKV/Core/crc32/zlib/crc32.cpp +0 -55
  83. package/MMKV/Core/crc32/zlib/crc32.h +0 -48
  84. package/MMKV/Core/crc32/zlib/zconf.h +0 -380
  85. package/MMKV/Core/crc32/zlib/zutil.h +0 -25
  86. package/MMKV/LICENSE.TXT +0 -193
  87. package/MMKV/README.md +0 -354
@@ -1,150 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <ItemGroup>
4
- <Filter Include="Header Files">
5
- <UniqueIdentifier>{A23FB4D7-B12B-3111-88E9-80ECCF93DBA8}</UniqueIdentifier>
6
- </Filter>
7
- <Filter Include="Source Files">
8
- <UniqueIdentifier>{047F57F7-8EBB-3570-BBF5-21BCA0934FD5}</UniqueIdentifier>
9
- </Filter>
10
- </ItemGroup>
11
- <ItemGroup>
12
- <ClCompile Include="CodedInputData.cpp">
13
- <Filter>Source Files</Filter>
14
- </ClCompile>
15
- <ClCompile Include="CodedOutputData.cpp">
16
- <Filter>Source Files</Filter>
17
- </ClCompile>
18
- <ClCompile Include="aes\AESCrypt.cpp">
19
- <Filter>Source Files</Filter>
20
- </ClCompile>
21
- <ClCompile Include="crc32\zlib\crc32.cpp">
22
- <Filter>Source Files</Filter>
23
- </ClCompile>
24
- <ClCompile Include="InterProcessLock.cpp">
25
- <Filter>Source Files</Filter>
26
- </ClCompile>
27
- <ClCompile Include="MemoryFile_Win32.cpp">
28
- <Filter>Source Files</Filter>
29
- </ClCompile>
30
- <ClCompile Include="MMBuffer.cpp">
31
- <Filter>Source Files</Filter>
32
- </ClCompile>
33
- <ClCompile Include="MMKV.cpp">
34
- <Filter>Source Files</Filter>
35
- </ClCompile>
36
- <ClCompile Include="MMKVLog.cpp">
37
- <Filter>Source Files</Filter>
38
- </ClCompile>
39
- <ClCompile Include="MiniPBCoder.cpp">
40
- <Filter>Source Files</Filter>
41
- </ClCompile>
42
- <ClCompile Include="PBUtility.cpp">
43
- <Filter>Source Files</Filter>
44
- </ClCompile>
45
- <ClCompile Include="ThreadLock_Win32.cpp">
46
- <Filter>Source Files</Filter>
47
- </ClCompile>
48
- <ClCompile Include="InterProcessLock_Win32.cpp">
49
- <Filter>Source Files</Filter>
50
- </ClCompile>
51
- <ClCompile Include="aes\openssl\openssl_aes_core.cpp">
52
- <Filter>Source Files</Filter>
53
- </ClCompile>
54
- <ClCompile Include="aes\openssl\openssl_cfb128.cpp">
55
- <Filter>Source Files</Filter>
56
- </ClCompile>
57
- <ClCompile Include="aes\openssl\openssl_md5_dgst.cpp">
58
- <Filter>Source Files</Filter>
59
- </ClCompile>
60
- <ClCompile Include="aes\openssl\openssl_md5_one.cpp">
61
- <Filter>Source Files</Filter>
62
- </ClCompile>
63
- <ClCompile Include="KeyValueHolder.cpp" />
64
- <ClCompile Include="CodedInputDataCrypt.cpp" />
65
- <ClCompile Include="MMKV_IO.cpp" />
66
- </ItemGroup>
67
- <ItemGroup>
68
- <ClInclude Include="CodedInputData.h">
69
- <Filter>Header Files</Filter>
70
- </ClInclude>
71
- <ClInclude Include="CodedOutputData.h">
72
- <Filter>Header Files</Filter>
73
- </ClInclude>
74
- <ClInclude Include="InterProcessLock.h">
75
- <Filter>Header Files</Filter>
76
- </ClInclude>
77
- <ClInclude Include="MemoryFile.h">
78
- <Filter>Header Files</Filter>
79
- </ClInclude>
80
- <ClInclude Include="MiniPBCoder.h">
81
- <Filter>Header Files</Filter>
82
- </ClInclude>
83
- <ClInclude Include="MMBuffer.h">
84
- <Filter>Header Files</Filter>
85
- </ClInclude>
86
- <ClInclude Include="MMKV.h">
87
- <Filter>Header Files</Filter>
88
- </ClInclude>
89
- <ClInclude Include="MMKVLog.h">
90
- <Filter>Header Files</Filter>
91
- </ClInclude>
92
- <ClInclude Include="crc32\zlib\crc32.h">
93
- <Filter>Header Files</Filter>
94
- </ClInclude>
95
- <ClInclude Include="crc32\zlib\zconf.h">
96
- <Filter>Header Files</Filter>
97
- </ClInclude>
98
- <ClInclude Include="crc32\zlib\zutil.h">
99
- <Filter>Header Files</Filter>
100
- </ClInclude>
101
- <ClInclude Include="aes\AESCrypt.h">
102
- <Filter>Header Files</Filter>
103
- </ClInclude>
104
- <ClInclude Include="crc32\Checksum.h">
105
- <Filter>Header Files</Filter>
106
- </ClInclude>
107
- <ClInclude Include="MMKVMetaInfo.hpp">
108
- <Filter>Header Files</Filter>
109
- </ClInclude>
110
- <ClInclude Include="MMKVPredef.h">
111
- <Filter>Header Files</Filter>
112
- </ClInclude>
113
- <ClInclude Include="PBEncodeItem.hpp">
114
- <Filter>Header Files</Filter>
115
- </ClInclude>
116
- <ClInclude Include="PBUtility.h">
117
- <Filter>Header Files</Filter>
118
- </ClInclude>
119
- <ClInclude Include="ScopedLock.hpp">
120
- <Filter>Header Files</Filter>
121
- </ClInclude>
122
- <ClInclude Include="ThreadLock.h">
123
- <Filter>Header Files</Filter>
124
- </ClInclude>
125
- <ClInclude Include="aes\openssl\openssl_aes.h">
126
- <Filter>Header Files</Filter>
127
- </ClInclude>
128
- <ClInclude Include="aes\openssl\openssl_aes_locl.h">
129
- <Filter>Header Files</Filter>
130
- </ClInclude>
131
- <ClInclude Include="aes\openssl\openssl_md5.h">
132
- <Filter>Header Files</Filter>
133
- </ClInclude>
134
- <ClInclude Include="aes\openssl\openssl_md5_locl.h">
135
- <Filter>Header Files</Filter>
136
- </ClInclude>
137
- <ClInclude Include="aes\openssl\openssl_opensslconf.h">
138
- <Filter>Header Files</Filter>
139
- </ClInclude>
140
- <ClInclude Include="aes\openssl\openssl_md32_common.h">
141
- <Filter>Header Files</Filter>
142
- </ClInclude>
143
- <ClInclude Include="aes\openssl\openssl_arm_arch.h">
144
- <Filter>Header Files</Filter>
145
- </ClInclude>
146
- <ClInclude Include="KeyValueHolder.h" />
147
- <ClInclude Include="CodedInputDataCrypt.h" />
148
- <ClInclude Include="MMKV_IO.h" />
149
- </ItemGroup>
150
- </Project>
@@ -1,75 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making
3
- * MMKV available.
4
- *
5
- * Copyright (C) 2018 THL A29 Limited, a Tencent company.
6
- * All rights reserved.
7
- *
8
- * Licensed under the BSD 3-Clause License (the "License"); you may not use
9
- * this file except in compliance with the License. You may obtain a copy of
10
- * the License at
11
- *
12
- * https://opensource.org/licenses/BSD-3-Clause
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
- #ifndef CHECKSUM_H
22
- #define CHECKSUM_H
23
- #ifdef __cplusplus
24
-
25
- #include "../MMKVPredef.h"
26
-
27
- #if MMKV_EMBED_ZLIB
28
-
29
- # include "zlib/zconf.h"
30
-
31
- namespace zlib {
32
-
33
- uLong crc32(uLong crc, const Bytef *buf, z_size_t len);
34
-
35
- } // namespace zlib
36
-
37
- # define ZLIB_CRC32(crc, buf, len) zlib::crc32(crc, buf, len)
38
-
39
- #else // MMKV_EMBED_ZLIB
40
-
41
- # include <zlib.h>
42
- // some old version of zlib doesn't define z_size_t
43
- # ifndef z_size_t
44
- typedef size_t z_size_t;
45
- # endif
46
- # define ZLIB_CRC32(crc, buf, len) ::crc32(crc, buf, static_cast<uInt>(len))
47
-
48
- #endif // MMKV_EMBED_ZLIB
49
-
50
-
51
- #if defined(__aarch64__) && defined(__linux__)
52
-
53
- # define MMKV_USE_ARMV8_CRC32
54
-
55
- namespace mmkv {
56
- uint32_t armv8_crc32(uint32_t crc, const uint8_t *buf, size_t len);
57
- }
58
-
59
- # ifdef MMKV_OHOS
60
- // getauxval(AT_HWCAP) in OHOS returns wrong value, we just assume all OHOS device have crc32 instr
61
- # define CRC32 mmkv::armv8_crc32
62
- # else
63
- // have to check CPU's instruction set dynamically
64
- typedef uint32_t (*CRC32_Func_t)(uint32_t crc, const uint8_t *buf, size_t len);
65
- extern CRC32_Func_t CRC32;
66
- # endif
67
-
68
- #else // defined(__aarch64__) && defined(__linux__)
69
-
70
- # define CRC32(crc, buf, len) ZLIB_CRC32(crc, buf, len)
71
-
72
- #endif // defined(__aarch64__) && defined(__linux__)
73
-
74
- #endif // __cplusplus
75
- #endif // CHECKSUM_H
@@ -1,134 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making
3
- * MMKV available.
4
- *
5
- * Copyright (C) 2020 THL A29 Limited, a Tencent company.
6
- * All rights reserved.
7
- *
8
- * Licensed under the BSD 3-Clause License (the "License"); you may not use
9
- * this file except in compliance with the License. You may obtain a copy of
10
- * the License at
11
- *
12
- * https://opensource.org/licenses/BSD-3-Clause
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
- #include "Checksum.h"
22
-
23
- #ifdef MMKV_USE_ARMV8_CRC32
24
-
25
- # ifdef CRC32
26
- // nothing to do
27
- # elif MMKV_EMBED_ZLIB
28
-
29
- static inline uint32_t _crc32Wrap(uint32_t crc, const uint8_t *buf, size_t len) {
30
- return static_cast<uint32_t>(zlib::crc32(crc, buf, static_cast<uInt>(len)));
31
- }
32
-
33
- CRC32_Func_t CRC32 = _crc32Wrap;
34
-
35
- # else
36
- # include <zlib.h>
37
-
38
- static inline uint32_t _crc32Wrap(uint32_t crc, const uint8_t *buf, size_t len) {
39
- return static_cast<uint32_t>(::crc32(crc, buf, static_cast<uInt>(len)));
40
- }
41
-
42
- CRC32_Func_t CRC32 = _crc32Wrap;
43
-
44
- # endif
45
-
46
- // targeting armv8 with crc instruction extension
47
- #if defined(__GNUC__) && !defined(__clang__)
48
- # define TARGET_ARM_CRC __attribute__((target("+crc")))
49
- # define __builtin_arm_crc32b(a, b) __builtin_aarch64_crc32b(a, b)
50
- # define __builtin_arm_crc32h(a, b) __builtin_aarch64_crc32h(a, b)
51
- # define __builtin_arm_crc32w(a, b) __builtin_aarch64_crc32w(a, b)
52
- # define __builtin_arm_crc32d(a, b) __builtin_aarch64_crc32x(a, b)
53
- #else
54
- # define TARGET_ARM_CRC __attribute__((target("crc")))
55
- #endif
56
-
57
- TARGET_ARM_CRC static inline uint32_t __crc32b(uint32_t a, uint8_t b) {
58
- return __builtin_arm_crc32b(a, b);
59
- }
60
-
61
- TARGET_ARM_CRC static inline uint32_t __crc32h(uint32_t a, uint16_t b) {
62
- return __builtin_arm_crc32h(a, b);
63
- }
64
-
65
- TARGET_ARM_CRC static inline uint32_t __crc32w(uint32_t a, uint32_t b) {
66
- return __builtin_arm_crc32w(a, b);
67
- }
68
-
69
- TARGET_ARM_CRC static inline uint32_t __crc32d(uint32_t a, uint64_t b) {
70
- return __builtin_arm_crc32d(a, b);
71
- }
72
-
73
- TARGET_ARM_CRC static inline uint32_t armv8_crc32_small(uint32_t crc, const uint8_t *buf, size_t len) {
74
- if (len >= sizeof(uint32_t)) {
75
- crc = __crc32w(crc, *(const uint32_t *) buf);
76
- buf += sizeof(uint32_t);
77
- len -= sizeof(uint32_t);
78
- }
79
- if (len >= sizeof(uint16_t)) {
80
- crc = __crc32h(crc, *(const uint16_t *) buf);
81
- buf += sizeof(uint16_t);
82
- len -= sizeof(uint16_t);
83
- }
84
- if (len >= sizeof(uint8_t)) {
85
- crc = __crc32b(crc, *(const uint8_t *) buf);
86
- }
87
-
88
- return crc;
89
- }
90
-
91
- namespace mmkv {
92
-
93
- TARGET_ARM_CRC uint32_t armv8_crc32(uint32_t crc, const uint8_t *buf, size_t len) {
94
-
95
- crc = crc ^ 0xffffffffUL;
96
-
97
- // roundup to 8 byte pointer
98
- auto offset = std::min(len, (uintptr_t) buf & 7);
99
- if (offset) {
100
- crc = armv8_crc32_small(crc, buf, offset);
101
- buf += offset;
102
- len -= offset;
103
- }
104
- if (!len) {
105
- return crc ^ 0xffffffffUL;
106
- }
107
-
108
- // unroll to 8 * 8 byte per loop
109
- auto ptr64 = (const uint64_t *) buf;
110
- for (constexpr auto step = 8 * sizeof(uint64_t); len >= step; len -= step) {
111
- crc = __crc32d(crc, *ptr64++);
112
- crc = __crc32d(crc, *ptr64++);
113
- crc = __crc32d(crc, *ptr64++);
114
- crc = __crc32d(crc, *ptr64++);
115
- crc = __crc32d(crc, *ptr64++);
116
- crc = __crc32d(crc, *ptr64++);
117
- crc = __crc32d(crc, *ptr64++);
118
- crc = __crc32d(crc, *ptr64++);
119
- }
120
-
121
- for (constexpr auto step = sizeof(uint64_t); len >= step; len -= step) {
122
- crc = __crc32d(crc, *ptr64++);
123
- }
124
-
125
- if (len) {
126
- crc = armv8_crc32_small(crc, (const uint8_t *) ptr64, len);
127
- }
128
-
129
- return crc ^ 0xffffffffUL;
130
- }
131
-
132
- } // namespace mmkv
133
-
134
- #endif // MMKV_USE_ARMV8_CRC32
@@ -1,60 +0,0 @@
1
- #
2
- # Tencent is pleased to support the open source community by making
3
- # MMKV available.
4
- #
5
- # Copyright (C) 2020 THL A29 Limited, a Tencent company.
6
- # All rights reserved.
7
- #
8
- # Licensed under the BSD 3-Clause License (the "License"); you may not use
9
- # this file except in compliance with the License. You may obtain a copy of
10
- # the License at
11
- #
12
- # https://opensource.org/licenses/BSD-3-Clause
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- # Sets the minimum version of CMake required to build the native library.
22
-
23
- cmake_minimum_required(VERSION 3.10.0)
24
-
25
- project(z)
26
-
27
- IF(APPLE)
28
- add_compile_definitions(FORCE_POSIX)
29
- ENDIF()
30
-
31
-
32
- # Creates and names a library, sets it as either STATIC
33
- # or SHARED, and provides the relative paths to its source code.
34
- # You can define multiple libraries, and CMake builds them for you.
35
- # Gradle automatically packages shared libraries with your APK.
36
-
37
- add_library( # Sets the name of the library.
38
- z
39
-
40
- # Sets the library as a shared library.
41
- STATIC
42
-
43
- # Provides a relative path to your source file(s).
44
- crc32.h
45
- crc32.cpp
46
- zconf.h
47
- zutil.h
48
- )
49
-
50
-
51
- set_target_properties(z PROPERTIES
52
- CXX_STANDARD 17
53
- CXX_EXTENSIONS OFF
54
- )
55
-
56
- # Specifies libraries CMake should link to your target library. You
57
- # can link multiple libraries, such as libraries you define in this
58
- # build script, prebuilt third-party libraries, or system libraries.
59
-
60
-
@@ -1,55 +0,0 @@
1
- /* crc32.c -- compute the CRC-32 of a data stream
2
- * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler
3
- * For conditions of distribution and use, see copyright notice in zlib.h
4
- *
5
- * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
6
- * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
7
- * tables for updating the shift register in one step with three exclusive-ors
8
- * instead of four steps with four exclusive-ors. This results in about a
9
- * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
10
- */
11
-
12
- /* @(#) $Id$ */
13
-
14
- #include "../../MMKVPredef.h"
15
-
16
- #if MMKV_EMBED_ZLIB
17
-
18
- #include "zutil.h" /* for STDC and FAR definitions */
19
-
20
- #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
21
- # define TBLS 1
22
-
23
- #include "crc32.h"
24
-
25
- namespace zlib {
26
-
27
- /* ========================================================================= */
28
- #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
29
- #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
30
-
31
- /* ========================================================================= */
32
- unsigned long local crc32_z(unsigned long crc, const unsigned char FAR *buf, z_size_t len)
33
- {
34
- if (buf == Z_NULL) return 0UL;
35
-
36
- crc = crc ^ 0xffffffffUL;
37
- while (len >= 8) {
38
- DO8;
39
- len -= 8;
40
- }
41
- if (len) do {
42
- DO1;
43
- } while (--len);
44
- return crc ^ 0xffffffffUL;
45
- }
46
-
47
- /* ========================================================================= */
48
-
49
- unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, z_size_t len) {
50
- return crc32_z(crc, buf, len);
51
- }
52
-
53
- } // namespace zlib
54
-
55
- #endif // MMKV_EMBED_ZLIB
@@ -1,48 +0,0 @@
1
- /* crc32.h -- tables for rapid CRC calculation
2
- * Generated automatically by crc32.c
3
- */
4
-
5
- local const z_crc_t FAR crc_table[TBLS][256] = {
6
- {0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x706af48fUL,
7
- 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, 0xe0d5e91eUL, 0x97d2d988UL,
8
- 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL,
9
- 0xf3b97148UL, 0x84be41deUL, 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL,
10
- 0x136c9856UL, 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
11
- 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, 0xa2677172UL,
12
- 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, 0x35b5a8faUL, 0x42b2986cUL,
13
- 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL,
14
- 0x26d930acUL, 0x51de003aUL, 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL,
15
- 0xcfba9599UL, 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
16
- 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, 0x01db7106UL,
17
- 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, 0x9fbfe4a5UL, 0xe8b8d433UL,
18
- 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL,
19
- 0x91646c97UL, 0xe6635c01UL, 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL,
20
- 0x6c0695edUL, 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
21
- 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, 0xfbd44c65UL,
22
- 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, 0x4adfa541UL, 0x3dd895d7UL,
23
- 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL,
24
- 0x44042d73UL, 0x33031de5UL, 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL,
25
- 0xbe0b1010UL, 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
26
- 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, 0x2eb40d81UL,
27
- 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, 0x03b6e20cUL, 0x74b1d29aUL,
28
- 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL,
29
- 0x0d6d6a3eUL, 0x7a6a5aa8UL, 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL,
30
- 0xf00f9344UL, 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
31
- 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, 0x67dd4accUL,
32
- 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, 0xd6d6a3e8UL, 0xa1d1937eUL,
33
- 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL,
34
- 0xd80d2bdaUL, 0xaf0a1b4cUL, 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL,
35
- 0x316e8eefUL, 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
36
- 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, 0xb2bd0b28UL,
37
- 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, 0x2cd99e8bUL, 0x5bdeae1dUL,
38
- 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL,
39
- 0x72076785UL, 0x05005713UL, 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL,
40
- 0x92d28e9bUL, 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
41
- 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, 0x18b74777UL,
42
- 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, 0x8f659effUL, 0xf862ae69UL,
43
- 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL,
44
- 0xa7672661UL, 0xd06016f7UL, 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL,
45
- 0x40df0b66UL, 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
46
- 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, 0xcdd70693UL,
47
- 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, 0x5d681b02UL, 0x2a6f2b94UL,
48
- 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, 0x2d02ef8dUL}};