koffi 2.3.6-beta.6 → 2.3.7

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 (276) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +2 -2
  3. package/src/cnoke/cnoke.js +3 -7
  4. package/src/cnoke/src/builder.js +9 -6
  5. package/src/cnoke/src/index.js +2 -2
  6. package/src/koffi/build/2.3.7/koffi_darwin_arm64/koffi.node +0 -0
  7. package/src/koffi/build/2.3.7/koffi_darwin_x64/koffi.node +0 -0
  8. package/src/koffi/build/2.3.7/koffi_freebsd_arm64/koffi.node +0 -0
  9. package/src/koffi/build/2.3.7/koffi_freebsd_ia32/koffi.node +0 -0
  10. package/src/koffi/build/2.3.7/koffi_freebsd_x64/koffi.node +0 -0
  11. package/src/koffi/build/2.3.7/koffi_linux_arm32hf/koffi.node +0 -0
  12. package/src/koffi/build/2.3.7/koffi_linux_arm64/koffi.node +0 -0
  13. package/src/koffi/build/2.3.7/koffi_linux_ia32/koffi.node +0 -0
  14. package/src/koffi/build/2.3.7/koffi_linux_riscv64hf64/koffi.node +0 -0
  15. package/src/koffi/build/2.3.7/koffi_linux_x64/koffi.node +0 -0
  16. package/src/koffi/build/2.3.7/koffi_openbsd_ia32/koffi.node +0 -0
  17. package/src/koffi/build/2.3.7/koffi_openbsd_x64/koffi.node +0 -0
  18. package/src/koffi/build/2.3.7/koffi_win32_arm64/koffi.node +0 -0
  19. package/src/koffi/build/2.3.7/koffi_win32_ia32/koffi.node +0 -0
  20. package/src/koffi/build/2.3.7/koffi_win32_x64/koffi.node +0 -0
  21. package/src/koffi/src/ffi.cc +2 -2
  22. package/src/koffi/src/index.d.ts +2 -2
  23. package/src/koffi/src/index.js +1 -0
  24. package/src/koffi/build/2.3.6-beta.6/koffi_darwin_arm64/koffi.node +0 -0
  25. package/src/koffi/build/2.3.6-beta.6/koffi_darwin_x64/koffi.node +0 -0
  26. package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_arm64/koffi.node +0 -0
  27. package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_ia32/koffi.node +0 -0
  28. package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_x64/koffi.node +0 -0
  29. package/src/koffi/build/2.3.6-beta.6/koffi_linux_arm32hf/koffi.node +0 -0
  30. package/src/koffi/build/2.3.6-beta.6/koffi_linux_arm64/koffi.node +0 -0
  31. package/src/koffi/build/2.3.6-beta.6/koffi_linux_ia32/koffi.node +0 -0
  32. package/src/koffi/build/2.3.6-beta.6/koffi_linux_riscv64hf64/koffi.node +0 -0
  33. package/src/koffi/build/2.3.6-beta.6/koffi_linux_x64/koffi.node +0 -0
  34. package/src/koffi/build/2.3.6-beta.6/koffi_openbsd_ia32/koffi.node +0 -0
  35. package/src/koffi/build/2.3.6-beta.6/koffi_openbsd_x64/koffi.node +0 -0
  36. package/src/koffi/build/2.3.6-beta.6/koffi_win32_arm64/koffi.node +0 -0
  37. package/src/koffi/build/2.3.6-beta.6/koffi_win32_arm64/koffi.pdb +0 -0
  38. package/src/koffi/build/2.3.6-beta.6/koffi_win32_ia32/koffi.node +0 -0
  39. package/src/koffi/build/2.3.6-beta.6/koffi_win32_ia32/koffi.pdb +0 -0
  40. package/src/koffi/build/2.3.6-beta.6/koffi_win32_x64/koffi.node +0 -0
  41. package/src/koffi/build/2.3.6-beta.6/koffi_win32_x64/koffi.pdb +0 -0
  42. package/vendor/brotli/BUILD +0 -144
  43. package/vendor/brotli/CMakeLists.txt +0 -421
  44. package/vendor/brotli/CONTRIBUTING.md +0 -27
  45. package/vendor/brotli/LICENSE +0 -19
  46. package/vendor/brotli/MANIFEST.in +0 -17
  47. package/vendor/brotli/Makefile +0 -55
  48. package/vendor/brotli/Makefile.am +0 -38
  49. package/vendor/brotli/README +0 -15
  50. package/vendor/brotli/README.md +0 -104
  51. package/vendor/brotli/WORKSPACE +0 -21
  52. package/vendor/brotli/bootstrap +0 -35
  53. package/vendor/brotli/c/common/constants.c +0 -15
  54. package/vendor/brotli/c/common/constants.h +0 -200
  55. package/vendor/brotli/c/common/context.c +0 -156
  56. package/vendor/brotli/c/common/context.h +0 -113
  57. package/vendor/brotli/c/common/dictionary.c +0 -5914
  58. package/vendor/brotli/c/common/dictionary.h +0 -64
  59. package/vendor/brotli/c/common/platform.c +0 -22
  60. package/vendor/brotli/c/common/platform.h +0 -596
  61. package/vendor/brotli/c/common/transform.c +0 -291
  62. package/vendor/brotli/c/common/transform.h +0 -85
  63. package/vendor/brotli/c/common/version.h +0 -26
  64. package/vendor/brotli/c/dec/bit_reader.c +0 -76
  65. package/vendor/brotli/c/dec/bit_reader.h +0 -351
  66. package/vendor/brotli/c/dec/decode.c +0 -2608
  67. package/vendor/brotli/c/dec/huffman.c +0 -339
  68. package/vendor/brotli/c/dec/huffman.h +0 -121
  69. package/vendor/brotli/c/dec/prefix.h +0 -732
  70. package/vendor/brotli/c/dec/state.c +0 -159
  71. package/vendor/brotli/c/dec/state.h +0 -365
  72. package/vendor/brotli/c/enc/backward_references.c +0 -145
  73. package/vendor/brotli/c/enc/backward_references.h +0 -39
  74. package/vendor/brotli/c/enc/backward_references_hq.c +0 -843
  75. package/vendor/brotli/c/enc/backward_references_hq.h +0 -95
  76. package/vendor/brotli/c/enc/backward_references_inc.h +0 -163
  77. package/vendor/brotli/c/enc/bit_cost.c +0 -35
  78. package/vendor/brotli/c/enc/bit_cost.h +0 -63
  79. package/vendor/brotli/c/enc/bit_cost_inc.h +0 -127
  80. package/vendor/brotli/c/enc/block_encoder_inc.h +0 -34
  81. package/vendor/brotli/c/enc/block_splitter.c +0 -194
  82. package/vendor/brotli/c/enc/block_splitter.h +0 -51
  83. package/vendor/brotli/c/enc/block_splitter_inc.h +0 -440
  84. package/vendor/brotli/c/enc/brotli_bit_stream.c +0 -1314
  85. package/vendor/brotli/c/enc/brotli_bit_stream.h +0 -84
  86. package/vendor/brotli/c/enc/cluster.c +0 -56
  87. package/vendor/brotli/c/enc/cluster.h +0 -48
  88. package/vendor/brotli/c/enc/cluster_inc.h +0 -320
  89. package/vendor/brotli/c/enc/command.c +0 -28
  90. package/vendor/brotli/c/enc/command.h +0 -190
  91. package/vendor/brotli/c/enc/compress_fragment.c +0 -790
  92. package/vendor/brotli/c/enc/compress_fragment.h +0 -61
  93. package/vendor/brotli/c/enc/compress_fragment_two_pass.c +0 -645
  94. package/vendor/brotli/c/enc/compress_fragment_two_pass.h +0 -54
  95. package/vendor/brotli/c/enc/dictionary_hash.c +0 -1846
  96. package/vendor/brotli/c/enc/dictionary_hash.h +0 -25
  97. package/vendor/brotli/c/enc/encode.c +0 -1927
  98. package/vendor/brotli/c/enc/encoder_dict.c +0 -33
  99. package/vendor/brotli/c/enc/encoder_dict.h +0 -43
  100. package/vendor/brotli/c/enc/entropy_encode.c +0 -503
  101. package/vendor/brotli/c/enc/entropy_encode.h +0 -122
  102. package/vendor/brotli/c/enc/entropy_encode_static.h +0 -539
  103. package/vendor/brotli/c/enc/fast_log.c +0 -105
  104. package/vendor/brotli/c/enc/fast_log.h +0 -66
  105. package/vendor/brotli/c/enc/find_match_length.h +0 -79
  106. package/vendor/brotli/c/enc/hash.h +0 -488
  107. package/vendor/brotli/c/enc/hash_composite_inc.h +0 -125
  108. package/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +0 -293
  109. package/vendor/brotli/c/enc/hash_longest_match64_inc.h +0 -267
  110. package/vendor/brotli/c/enc/hash_longest_match_inc.h +0 -262
  111. package/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +0 -266
  112. package/vendor/brotli/c/enc/hash_rolling_inc.h +0 -212
  113. package/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +0 -329
  114. package/vendor/brotli/c/enc/histogram.c +0 -100
  115. package/vendor/brotli/c/enc/histogram.h +0 -63
  116. package/vendor/brotli/c/enc/histogram_inc.h +0 -51
  117. package/vendor/brotli/c/enc/literal_cost.c +0 -175
  118. package/vendor/brotli/c/enc/literal_cost.h +0 -30
  119. package/vendor/brotli/c/enc/memory.c +0 -170
  120. package/vendor/brotli/c/enc/memory.h +0 -114
  121. package/vendor/brotli/c/enc/metablock.c +0 -663
  122. package/vendor/brotli/c/enc/metablock.h +0 -105
  123. package/vendor/brotli/c/enc/metablock_inc.h +0 -183
  124. package/vendor/brotli/c/enc/params.h +0 -46
  125. package/vendor/brotli/c/enc/prefix.h +0 -53
  126. package/vendor/brotli/c/enc/quality.h +0 -165
  127. package/vendor/brotli/c/enc/ringbuffer.h +0 -167
  128. package/vendor/brotli/c/enc/static_dict.c +0 -486
  129. package/vendor/brotli/c/enc/static_dict.h +0 -40
  130. package/vendor/brotli/c/enc/static_dict_lut.h +0 -5864
  131. package/vendor/brotli/c/enc/utf8_util.c +0 -85
  132. package/vendor/brotli/c/enc/utf8_util.h +0 -32
  133. package/vendor/brotli/c/enc/write_bits.h +0 -87
  134. package/vendor/brotli/c/include/brotli/decode.h +0 -344
  135. package/vendor/brotli/c/include/brotli/encode.h +0 -448
  136. package/vendor/brotli/c/include/brotli/port.h +0 -288
  137. package/vendor/brotli/c/include/brotli/types.h +0 -83
  138. package/vendor/brotli/c/tools/brotli.c +0 -1116
  139. package/vendor/brotli/c/tools/brotli.md +0 -107
  140. package/vendor/brotli/compiler_config_setting.bzl +0 -28
  141. package/vendor/brotli/configure +0 -8
  142. package/vendor/brotli/configure-cmake +0 -318
  143. package/vendor/brotli/configure.ac +0 -14
  144. package/vendor/brotli/docs/brotli.1 +0 -132
  145. package/vendor/brotli/docs/constants.h.3 +0 -47
  146. package/vendor/brotli/docs/decode.h.3 +0 -415
  147. package/vendor/brotli/docs/encode.h.3 +0 -586
  148. package/vendor/brotli/docs/types.h.3 +0 -117
  149. package/vendor/brotli/premake5.lua +0 -78
  150. package/vendor/brotli/python/Makefile +0 -57
  151. package/vendor/brotli/python/README.md +0 -54
  152. package/vendor/brotli/python/_brotli.cc +0 -753
  153. package/vendor/brotli/python/bro.py +0 -160
  154. package/vendor/brotli/python/brotli.py +0 -56
  155. package/vendor/brotli/python/tests/__init__.py +0 -0
  156. package/vendor/brotli/python/tests/_test_utils.py +0 -112
  157. package/vendor/brotli/python/tests/bro_test.py +0 -102
  158. package/vendor/brotli/python/tests/compress_test.py +0 -41
  159. package/vendor/brotli/python/tests/compressor_test.py +0 -94
  160. package/vendor/brotli/python/tests/decompress_test.py +0 -42
  161. package/vendor/brotli/python/tests/decompressor_test.py +0 -59
  162. package/vendor/brotli/scripts/libbrotlicommon.pc.in +0 -11
  163. package/vendor/brotli/scripts/libbrotlidec.pc.in +0 -12
  164. package/vendor/brotli/scripts/libbrotlienc.pc.in +0 -12
  165. package/vendor/brotli/scripts/sources.lst +0 -104
  166. package/vendor/brotli/setup.cfg +0 -5
  167. package/vendor/brotli/setup.py +0 -293
  168. package/vendor/brotli/tests/Makefile +0 -17
  169. package/vendor/brotli/tests/compatibility_test.sh +0 -25
  170. package/vendor/brotli/tests/roundtrip_test.sh +0 -36
  171. package/vendor/brotli/tests/run-compatibility-test.cmake +0 -31
  172. package/vendor/brotli/tests/run-roundtrip-test.cmake +0 -36
  173. package/vendor/brotli/tests/testdata/empty +0 -0
  174. package/vendor/brotli/tests/testdata/empty.compressed +0 -1
  175. package/vendor/brotli/tests/testdata/ukkonooa +0 -1
  176. package/vendor/brotli/tests/testdata/ukkonooa.compressed +0 -0
  177. package/vendor/dragonbox/CMakeLists.txt +0 -123
  178. package/vendor/dragonbox/LICENSE-Apache2-LLVM +0 -218
  179. package/vendor/dragonbox/LICENSE-Boost +0 -23
  180. package/vendor/dragonbox/README.md +0 -277
  181. package/vendor/dragonbox/cmake/dragonboxConfig.cmake +0 -1
  182. package/vendor/dragonbox/include/dragonbox/dragonbox.h +0 -2674
  183. package/vendor/dragonbox/include/dragonbox/dragonbox_to_chars.h +0 -108
  184. package/vendor/dragonbox/other_files/Dragonbox.pdf +0 -0
  185. package/vendor/dragonbox/other_files/Dragonbox_old.pdf +0 -0
  186. package/vendor/dragonbox/other_files/milo_benchmark.png +0 -0
  187. package/vendor/dragonbox/other_files/unknown_win64_vc2019.html +0 -540
  188. package/vendor/dragonbox/other_files/unknown_win64_vc2019_randomdigit_time.png +0 -0
  189. package/vendor/dragonbox/source/dragonbox_to_chars.cpp +0 -303
  190. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/CMakeLists.txt +0 -24
  191. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.cpp +0 -238
  192. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.h +0 -95
  193. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/grisu_exact.h +0 -2666
  194. package/vendor/dragonbox/subproject/3rdparty/ryu/CMakeLists.txt +0 -16
  195. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/common.h +0 -114
  196. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s.c +0 -509
  197. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_full_table.h +0 -367
  198. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_intrinsics.h +0 -357
  199. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/digit_table.h +0 -35
  200. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s.c +0 -345
  201. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_full_table.h +0 -55
  202. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_intrinsics.h +0 -128
  203. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/ryu.h +0 -46
  204. package/vendor/dragonbox/subproject/3rdparty/schubfach/CMakeLists.txt +0 -22
  205. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.cc +0 -699
  206. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.h +0 -31
  207. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.cc +0 -1354
  208. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.h +0 -31
  209. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/example_shaded_plots.m +0 -68
  210. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/license.txt +0 -25
  211. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution.m +0 -92
  212. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution_prctile.m +0 -121
  213. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_histogram_shaded.m +0 -99
  214. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_shaded.m +0 -93
  215. package/vendor/dragonbox/subproject/benchmark/CMakeLists.txt +0 -65
  216. package/vendor/dragonbox/subproject/benchmark/include/benchmark.h +0 -40
  217. package/vendor/dragonbox/subproject/benchmark/matlab/plot_benchmarks.m +0 -22
  218. package/vendor/dragonbox/subproject/benchmark/matlab/plot_digit_benchmark.m +0 -78
  219. package/vendor/dragonbox/subproject/benchmark/matlab/plot_uniform_benchmark.m +0 -95
  220. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_clang.png +0 -0
  221. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_msvc.png +0 -0
  222. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_clang.png +0 -0
  223. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_msvc.png +0 -0
  224. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_clang.png +0 -0
  225. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_msvc.png +0 -0
  226. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_clang.png +0 -0
  227. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_msvc.png +0 -0
  228. package/vendor/dragonbox/subproject/benchmark/source/benchmark.cpp +0 -238
  229. package/vendor/dragonbox/subproject/benchmark/source/dragonbox.cpp +0 -30
  230. package/vendor/dragonbox/subproject/benchmark/source/grisu_exact.cpp +0 -36
  231. package/vendor/dragonbox/subproject/benchmark/source/ryu.cpp +0 -27
  232. package/vendor/dragonbox/subproject/benchmark/source/schubfach.cpp +0 -31
  233. package/vendor/dragonbox/subproject/common/CMakeLists.txt +0 -42
  234. package/vendor/dragonbox/subproject/common/include/best_rational_approx.h +0 -97
  235. package/vendor/dragonbox/subproject/common/include/big_uint.h +0 -218
  236. package/vendor/dragonbox/subproject/common/include/continued_fractions.h +0 -174
  237. package/vendor/dragonbox/subproject/common/include/good_rational_approx.h +0 -267
  238. package/vendor/dragonbox/subproject/common/include/random_float.h +0 -182
  239. package/vendor/dragonbox/subproject/common/include/rational_continued_fractions.h +0 -57
  240. package/vendor/dragonbox/subproject/common/source/big_uint.cpp +0 -602
  241. package/vendor/dragonbox/subproject/meta/CMakeLists.txt +0 -41
  242. package/vendor/dragonbox/subproject/meta/results/binary32_generated_cache.txt +0 -82
  243. package/vendor/dragonbox/subproject/meta/results/binary64_compressed_cache_error_table.txt +0 -10
  244. package/vendor/dragonbox/subproject/meta/results/binary64_generated_cache.txt +0 -623
  245. package/vendor/dragonbox/subproject/meta/source/generate_cache.cpp +0 -126
  246. package/vendor/dragonbox/subproject/meta/source/live_test.cpp +0 -81
  247. package/vendor/dragonbox/subproject/meta/source/perf_test.cpp +0 -104
  248. package/vendor/dragonbox/subproject/meta/source/sandbox.cpp +0 -20
  249. package/vendor/dragonbox/subproject/test/CMakeLists.txt +0 -70
  250. package/vendor/dragonbox/subproject/test/results/binary32.csv +0 -255
  251. package/vendor/dragonbox/subproject/test/results/binary64.csv +0 -2047
  252. package/vendor/dragonbox/subproject/test/results/plot_required_bits.m +0 -18
  253. package/vendor/dragonbox/subproject/test/source/test_all_shorter_interval_cases.cpp +0 -88
  254. package/vendor/dragonbox/subproject/test/source/uniform_random_test.cpp +0 -95
  255. package/vendor/dragonbox/subproject/test/source/verify_cache_precision.cpp +0 -338
  256. package/vendor/dragonbox/subproject/test/source/verify_compressed_cache.cpp +0 -154
  257. package/vendor/dragonbox/subproject/test/source/verify_fast_multiplication.cpp +0 -168
  258. package/vendor/dragonbox/subproject/test/source/verify_log_computation.cpp +0 -251
  259. package/vendor/dragonbox/subproject/test/source/verify_magic_division.cpp +0 -113
  260. package/vendor/miniz/ChangeLog.md +0 -239
  261. package/vendor/miniz/LICENSE +0 -22
  262. package/vendor/miniz/examples/example1.c +0 -105
  263. package/vendor/miniz/examples/example2.c +0 -164
  264. package/vendor/miniz/examples/example3.c +0 -269
  265. package/vendor/miniz/examples/example4.c +0 -102
  266. package/vendor/miniz/examples/example5.c +0 -327
  267. package/vendor/miniz/examples/example6.c +0 -166
  268. package/vendor/miniz/miniz.c +0 -7835
  269. package/vendor/miniz/miniz.h +0 -1422
  270. package/vendor/miniz/readme.md +0 -46
  271. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_arm64/koffi.exp +0 -0
  272. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_arm64/koffi.lib +0 -0
  273. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_ia32/koffi.exp +0 -0
  274. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_ia32/koffi.lib +0 -0
  275. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_x64/koffi.exp +0 -0
  276. /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_x64/koffi.lib +0 -0
@@ -1,64 +0,0 @@
1
- /* Copyright 2013 Google Inc. All Rights Reserved.
2
-
3
- Distributed under MIT license.
4
- See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
- */
6
-
7
- /* Collection of static dictionary words. */
8
-
9
- #ifndef BROTLI_COMMON_DICTIONARY_H_
10
- #define BROTLI_COMMON_DICTIONARY_H_
11
-
12
- #include <brotli/port.h>
13
- #include <brotli/types.h>
14
-
15
- #if defined(__cplusplus) || defined(c_plusplus)
16
- extern "C" {
17
- #endif
18
-
19
- typedef struct BrotliDictionary {
20
- /**
21
- * Number of bits to encode index of dictionary word in a bucket.
22
- *
23
- * Specification: Appendix A. Static Dictionary Data
24
- *
25
- * Words in a dictionary are bucketed by length.
26
- * @c 0 means that there are no words of a given length.
27
- * Dictionary consists of words with length of [4..24] bytes.
28
- * Values at [0..3] and [25..31] indices should not be addressed.
29
- */
30
- uint8_t size_bits_by_length[32];
31
-
32
- /* assert(offset[i + 1] == offset[i] + (bits[i] ? (i << bits[i]) : 0)) */
33
- uint32_t offsets_by_length[32];
34
-
35
- /* assert(data_size == offsets_by_length[31]) */
36
- size_t data_size;
37
-
38
- /* Data array is not bound, and should obey to size_bits_by_length values.
39
- Specified size matches default (RFC 7932) dictionary. Its size is
40
- defined by data_size */
41
- const uint8_t* data;
42
- } BrotliDictionary;
43
-
44
- BROTLI_COMMON_API const BrotliDictionary* BrotliGetDictionary(void);
45
-
46
- /**
47
- * Sets dictionary data.
48
- *
49
- * When dictionary data is already set / present, this method is no-op.
50
- *
51
- * Dictionary data MUST be provided before BrotliGetDictionary is invoked.
52
- * This method is used ONLY in multi-client environment (e.g. C + Java),
53
- * to reduce storage by sharing single dictionary between implementations.
54
- */
55
- BROTLI_COMMON_API void BrotliSetDictionaryData(const uint8_t* data);
56
-
57
- #define BROTLI_MIN_DICTIONARY_WORD_LENGTH 4
58
- #define BROTLI_MAX_DICTIONARY_WORD_LENGTH 24
59
-
60
- #if defined(__cplusplus) || defined(c_plusplus)
61
- } /* extern "C" */
62
- #endif
63
-
64
- #endif /* BROTLI_COMMON_DICTIONARY_H_ */
@@ -1,22 +0,0 @@
1
- /* Copyright 2016 Google Inc. All Rights Reserved.
2
-
3
- Distributed under MIT license.
4
- See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
- */
6
-
7
- #include <stdlib.h>
8
-
9
- #include "./platform.h"
10
- #include <brotli/types.h>
11
-
12
- /* Default brotli_alloc_func */
13
- void* BrotliDefaultAllocFunc(void* opaque, size_t size) {
14
- BROTLI_UNUSED(opaque);
15
- return malloc(size);
16
- }
17
-
18
- /* Default brotli_free_func */
19
- void BrotliDefaultFreeFunc(void* opaque, void* address) {
20
- BROTLI_UNUSED(opaque);
21
- free(address);
22
- }
@@ -1,596 +0,0 @@
1
- /* Copyright 2016 Google Inc. All Rights Reserved.
2
-
3
- Distributed under MIT license.
4
- See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
- */
6
-
7
- /* Macros for compiler / platform specific features and build options.
8
-
9
- Build options are:
10
- * BROTLI_BUILD_32_BIT disables 64-bit optimizations
11
- * BROTLI_BUILD_64_BIT forces to use 64-bit optimizations
12
- * BROTLI_BUILD_BIG_ENDIAN forces to use big-endian optimizations
13
- * BROTLI_BUILD_ENDIAN_NEUTRAL disables endian-aware optimizations
14
- * BROTLI_BUILD_LITTLE_ENDIAN forces to use little-endian optimizations
15
- * BROTLI_BUILD_PORTABLE disables dangerous optimizations, like unaligned
16
- read and overlapping memcpy; this reduces decompression speed by 5%
17
- * BROTLI_BUILD_NO_RBIT disables "rbit" optimization for ARM CPUs
18
- * BROTLI_DEBUG dumps file name and line number when decoder detects stream
19
- or memory error
20
- * BROTLI_ENABLE_LOG enables asserts and dumps various state information
21
- */
22
-
23
- #ifndef BROTLI_COMMON_PLATFORM_H_
24
- #define BROTLI_COMMON_PLATFORM_H_
25
-
26
- #include <string.h> /* memcpy */
27
-
28
- #include <brotli/port.h>
29
- #include <brotli/types.h>
30
-
31
- #if defined(OS_LINUX) || defined(OS_CYGWIN) || defined(__EMSCRIPTEN__)
32
- #include <endian.h>
33
- #elif defined(OS_FREEBSD)
34
- #include <machine/endian.h>
35
- #elif defined(OS_MACOSX)
36
- #include <machine/endian.h>
37
- /* Let's try and follow the Linux convention */
38
- #define BROTLI_X_BYTE_ORDER BYTE_ORDER
39
- #define BROTLI_X_LITTLE_ENDIAN LITTLE_ENDIAN
40
- #define BROTLI_X_BIG_ENDIAN BIG_ENDIAN
41
- #endif
42
-
43
- #if BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
44
- #include <intrin.h>
45
- #endif
46
-
47
- #if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG)
48
- #include <assert.h>
49
- #include <stdio.h>
50
- #endif
51
-
52
- /* The following macros were borrowed from https://github.com/nemequ/hedley
53
- * with permission of original author - Evan Nemerson <evan@nemerson.com> */
54
-
55
- /* >>> >>> >>> hedley macros */
56
-
57
- /* Define "BROTLI_PREDICT_TRUE" and "BROTLI_PREDICT_FALSE" macros for capable
58
- compilers.
59
-
60
- To apply compiler hint, enclose the branching condition into macros, like this:
61
-
62
- if (BROTLI_PREDICT_TRUE(zero == 0)) {
63
- // main execution path
64
- } else {
65
- // compiler should place this code outside of main execution path
66
- }
67
-
68
- OR:
69
-
70
- if (BROTLI_PREDICT_FALSE(something_rare_or_unexpected_happens)) {
71
- // compiler should place this code outside of main execution path
72
- }
73
-
74
- */
75
- #if BROTLI_GNUC_HAS_BUILTIN(__builtin_expect, 3, 0, 0) || \
76
- BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \
77
- BROTLI_SUNPRO_VERSION_CHECK(5, 15, 0) || \
78
- BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \
79
- BROTLI_IBM_VERSION_CHECK(10, 1, 0) || \
80
- BROTLI_TI_VERSION_CHECK(7, 3, 0) || \
81
- BROTLI_TINYC_VERSION_CHECK(0, 9, 27)
82
- #define BROTLI_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
83
- #define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
84
- #else
85
- #define BROTLI_PREDICT_FALSE(x) (x)
86
- #define BROTLI_PREDICT_TRUE(x) (x)
87
- #endif
88
-
89
- #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
90
- !defined(__cplusplus)
91
- #define BROTLI_RESTRICT restrict
92
- #elif BROTLI_GNUC_VERSION_CHECK(3, 1, 0) || \
93
- BROTLI_MSVC_VERSION_CHECK(14, 0, 0) || \
94
- BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \
95
- BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \
96
- BROTLI_IBM_VERSION_CHECK(10, 1, 0) || \
97
- BROTLI_PGI_VERSION_CHECK(17, 10, 0) || \
98
- BROTLI_TI_VERSION_CHECK(8, 0, 0) || \
99
- BROTLI_IAR_VERSION_CHECK(8, 0, 0) || \
100
- (BROTLI_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus))
101
- #define BROTLI_RESTRICT __restrict
102
- #elif BROTLI_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus)
103
- #define BROTLI_RESTRICT _Restrict
104
- #else
105
- #define BROTLI_RESTRICT
106
- #endif
107
-
108
- #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
109
- (defined(__cplusplus) && (__cplusplus >= 199711L))
110
- #define BROTLI_MAYBE_INLINE inline
111
- #elif defined(__GNUC_STDC_INLINE__) || defined(__GNUC_GNU_INLINE__) || \
112
- BROTLI_ARM_VERSION_CHECK(6, 2, 0)
113
- #define BROTLI_MAYBE_INLINE __inline__
114
- #elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0) || \
115
- BROTLI_ARM_VERSION_CHECK(4, 1, 0) || BROTLI_TI_VERSION_CHECK(8, 0, 0)
116
- #define BROTLI_MAYBE_INLINE __inline
117
- #else
118
- #define BROTLI_MAYBE_INLINE
119
- #endif
120
-
121
- #if BROTLI_GNUC_HAS_ATTRIBUTE(always_inline, 4, 0, 0) || \
122
- BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \
123
- BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \
124
- BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \
125
- BROTLI_IBM_VERSION_CHECK(10, 1, 0) || \
126
- BROTLI_TI_VERSION_CHECK(8, 0, 0) || \
127
- (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
128
- #define BROTLI_INLINE BROTLI_MAYBE_INLINE __attribute__((__always_inline__))
129
- #elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
130
- #define BROTLI_INLINE BROTLI_MAYBE_INLINE __forceinline
131
- #elif BROTLI_TI_VERSION_CHECK(7, 0, 0) && defined(__cplusplus)
132
- #define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
133
- #elif BROTLI_IAR_VERSION_CHECK(8, 0, 0)
134
- #define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("inline=forced")
135
- #else
136
- #define BROTLI_INLINE BROTLI_MAYBE_INLINE
137
- #endif
138
-
139
- #if BROTLI_GNUC_HAS_ATTRIBUTE(noinline, 4, 0, 0) || \
140
- BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \
141
- BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \
142
- BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \
143
- BROTLI_IBM_VERSION_CHECK(10, 1, 0) || \
144
- BROTLI_TI_VERSION_CHECK(8, 0, 0) || \
145
- (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
146
- #define BROTLI_NOINLINE __attribute__((__noinline__))
147
- #elif BROTLI_MSVC_VERSION_CHECK(13, 10, 0)
148
- #define BROTLI_NOINLINE __declspec(noinline)
149
- #elif BROTLI_PGI_VERSION_CHECK(10, 2, 0)
150
- #define BROTLI_NOINLINE _Pragma("noinline")
151
- #elif BROTLI_TI_VERSION_CHECK(6, 0, 0) && defined(__cplusplus)
152
- #define BROTLI_NOINLINE _Pragma("FUNC_CANNOT_INLINE;")
153
- #elif BROTLI_IAR_VERSION_CHECK(8, 0, 0)
154
- #define BROTLI_NOINLINE _Pragma("inline=never")
155
- #else
156
- #define BROTLI_NOINLINE
157
- #endif
158
-
159
- /* BROTLI_INTERNAL could be defined to override visibility, e.g. for tests. */
160
- #if !defined(BROTLI_INTERNAL)
161
- #if defined(_WIN32) || defined(__CYGWIN__)
162
- #define BROTLI_INTERNAL
163
- #elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) || \
164
- BROTLI_TI_VERSION_CHECK(8, 0, 0) || \
165
- BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \
166
- BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \
167
- BROTLI_IBM_VERSION_CHECK(13, 1, 0) || \
168
- BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \
169
- (BROTLI_TI_VERSION_CHECK(7, 3, 0) && \
170
- defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__))
171
- #define BROTLI_INTERNAL __attribute__ ((visibility ("hidden")))
172
- #else
173
- #define BROTLI_INTERNAL
174
- #endif
175
- #endif
176
-
177
- /* <<< <<< <<< end of hedley macros. */
178
-
179
- #if BROTLI_GNUC_HAS_ATTRIBUTE(unused, 2, 7, 0) || \
180
- BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
181
- #define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE __attribute__ ((unused))
182
- #else
183
- #define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE
184
- #endif
185
-
186
- #if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0)
187
- #define BROTLI_ALIGNED(N) __attribute__((aligned(N)))
188
- #else
189
- #define BROTLI_ALIGNED(N)
190
- #endif
191
-
192
- #if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \
193
- (defined(M_ARM) && (M_ARM == 7))
194
- #define BROTLI_TARGET_ARMV7
195
- #endif /* ARMv7 */
196
-
197
- #if (defined(__ARM_ARCH) && (__ARM_ARCH == 8)) || \
198
- defined(__aarch64__) || defined(__ARM64_ARCH_8__)
199
- #define BROTLI_TARGET_ARMV8_ANY
200
-
201
- #if defined(__ARM_32BIT_STATE)
202
- #define BROTLI_TARGET_ARMV8_32
203
- #elif defined(__ARM_64BIT_STATE)
204
- #define BROTLI_TARGET_ARMV8_64
205
- #endif
206
-
207
- #endif /* ARMv8 */
208
-
209
- #if defined(__ARM_NEON__) || defined(__ARM_NEON)
210
- #define BROTLI_TARGET_NEON
211
- #endif
212
-
213
- #if defined(__i386) || defined(_M_IX86)
214
- #define BROTLI_TARGET_X86
215
- #endif
216
-
217
- #if defined(__x86_64__) || defined(_M_X64)
218
- #define BROTLI_TARGET_X64
219
- #endif
220
-
221
- #if defined(__PPC64__)
222
- #define BROTLI_TARGET_POWERPC64
223
- #endif
224
-
225
- #if defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
226
- #define BROTLI_TARGET_RISCV64
227
- #endif
228
-
229
- #if defined(BROTLI_BUILD_64_BIT)
230
- #define BROTLI_64_BITS 1
231
- #elif defined(BROTLI_BUILD_32_BIT)
232
- #define BROTLI_64_BITS 0
233
- #elif defined(BROTLI_TARGET_X64) || defined(BROTLI_TARGET_ARMV8_64) || \
234
- defined(BROTLI_TARGET_POWERPC64) || defined(BROTLI_TARGET_RISCV64)
235
- #define BROTLI_64_BITS 1
236
- #else
237
- #define BROTLI_64_BITS 0
238
- #endif
239
-
240
- #if (BROTLI_64_BITS)
241
- #define brotli_reg_t uint64_t
242
- #else
243
- #define brotli_reg_t uint32_t
244
- #endif
245
-
246
- #if defined(BROTLI_BUILD_BIG_ENDIAN)
247
- #define BROTLI_BIG_ENDIAN 1
248
- #elif defined(BROTLI_BUILD_LITTLE_ENDIAN)
249
- #define BROTLI_LITTLE_ENDIAN 1
250
- #elif defined(BROTLI_BUILD_ENDIAN_NEUTRAL)
251
- /* Just break elif chain. */
252
- #elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
253
- #define BROTLI_LITTLE_ENDIAN 1
254
- #elif defined(_WIN32) || defined(BROTLI_TARGET_X64)
255
- /* Win32 & x64 can currently always be assumed to be little endian */
256
- #define BROTLI_LITTLE_ENDIAN 1
257
- #elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
258
- #define BROTLI_BIG_ENDIAN 1
259
- #elif defined(BROTLI_X_BYTE_ORDER)
260
- #if BROTLI_X_BYTE_ORDER == BROTLI_X_LITTLE_ENDIAN
261
- #define BROTLI_LITTLE_ENDIAN 1
262
- #elif BROTLI_X_BYTE_ORDER == BROTLI_X_BIG_ENDIAN
263
- #define BROTLI_BIG_ENDIAN 1
264
- #endif
265
- #endif /* BROTLI_X_BYTE_ORDER */
266
-
267
- #if !defined(BROTLI_LITTLE_ENDIAN)
268
- #define BROTLI_LITTLE_ENDIAN 0
269
- #endif
270
-
271
- #if !defined(BROTLI_BIG_ENDIAN)
272
- #define BROTLI_BIG_ENDIAN 0
273
- #endif
274
-
275
- #if defined(BROTLI_X_BYTE_ORDER)
276
- #undef BROTLI_X_BYTE_ORDER
277
- #undef BROTLI_X_LITTLE_ENDIAN
278
- #undef BROTLI_X_BIG_ENDIAN
279
- #endif
280
-
281
- #if defined(BROTLI_BUILD_PORTABLE)
282
- #define BROTLI_ALIGNED_READ (!!1)
283
- #elif !defined(NDEBUG)
284
- #define BROTLI_ALIGNED_READ (!!1)
285
- #elif defined(BROTLI_TARGET_X86) || defined(BROTLI_TARGET_X64) || \
286
- defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY) || \
287
- defined(BROTLI_TARGET_RISCV64)
288
- /* Allow unaligned read only for white-listed CPUs. */
289
- #define BROTLI_ALIGNED_READ (!!0)
290
- #else
291
- #define BROTLI_ALIGNED_READ (!!1)
292
- #endif
293
-
294
- #if BROTLI_ALIGNED_READ
295
- /* Portable unaligned memory access: read / write values via memcpy. */
296
- static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {
297
- uint16_t t;
298
- memcpy(&t, p, sizeof t);
299
- return t;
300
- }
301
- static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) {
302
- uint32_t t;
303
- memcpy(&t, p, sizeof t);
304
- return t;
305
- }
306
- static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
307
- uint64_t t;
308
- memcpy(&t, p, sizeof t);
309
- return t;
310
- }
311
- static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
312
- memcpy(p, &v, sizeof v);
313
- }
314
- #else /* BROTLI_ALIGNED_READ */
315
- /* Unaligned memory access is allowed: just cast pointer to requested type. */
316
- #if BROTLI_SANITIZED
317
- /* Consider we have an unaligned load/store of 4 bytes from address 0x...05.
318
- AddressSanitizer will treat it as a 3-byte access to the range 05:07 and
319
- will miss a bug if 08 is the first unaddressable byte.
320
- ThreadSanitizer will also treat this as a 3-byte access to 05:07 and will
321
- miss a race between this access and some other accesses to 08.
322
- MemorySanitizer will correctly propagate the shadow on unaligned stores
323
- and correctly report bugs on unaligned loads, but it may not properly
324
- update and report the origin of the uninitialized memory.
325
- For all three tools, replacing an unaligned access with a tool-specific
326
- callback solves the problem. */
327
- #if defined(__cplusplus)
328
- extern "C" {
329
- #endif /* __cplusplus */
330
- uint16_t __sanitizer_unaligned_load16(const void* p);
331
- uint32_t __sanitizer_unaligned_load32(const void* p);
332
- uint64_t __sanitizer_unaligned_load64(const void* p);
333
- void __sanitizer_unaligned_store64(void* p, uint64_t v);
334
- #if defined(__cplusplus)
335
- } /* extern "C" */
336
- #endif /* __cplusplus */
337
- #define BrotliUnalignedRead16 __sanitizer_unaligned_load16
338
- #define BrotliUnalignedRead32 __sanitizer_unaligned_load32
339
- #define BrotliUnalignedRead64 __sanitizer_unaligned_load64
340
- #define BrotliUnalignedWrite64 __sanitizer_unaligned_store64
341
- #else /* BROTLI_SANITIZED */
342
- static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {
343
- return *(const uint16_t*)p;
344
- }
345
- static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) {
346
- return *(const uint32_t*)p;
347
- }
348
- #if (BROTLI_64_BITS)
349
- static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
350
- return *(const uint64_t*)p;
351
- }
352
- static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
353
- *(uint64_t*)p = v;
354
- }
355
- #else /* BROTLI_64_BITS */
356
- /* Avoid emitting LDRD / STRD, which require properly aligned address. */
357
- /* If __attribute__(aligned) is available, use that. Otherwise, memcpy. */
358
-
359
- #if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0)
360
- typedef BROTLI_ALIGNED(1) uint64_t brotli_unaligned_uint64_t;
361
-
362
- static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
363
- return (uint64_t) ((const brotli_unaligned_uint64_t*) p)[0];
364
- }
365
- static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
366
- brotli_unaligned_uint64_t* dwords = (brotli_unaligned_uint64_t*) p;
367
- dwords[0] = (brotli_unaligned_uint64_t) v;
368
- }
369
- #else /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */
370
- static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
371
- uint64_t v;
372
- memcpy(&v, p, sizeof(uint64_t));
373
- return v;
374
- }
375
-
376
- static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
377
- memcpy(p, &v, sizeof(uint64_t));
378
- }
379
- #endif /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */
380
- #endif /* BROTLI_64_BITS */
381
- #endif /* BROTLI_SANITIZED */
382
- #endif /* BROTLI_ALIGNED_READ */
383
-
384
- #if BROTLI_LITTLE_ENDIAN
385
- /* Straight endianness. Just read / write values. */
386
- #define BROTLI_UNALIGNED_LOAD16LE BrotliUnalignedRead16
387
- #define BROTLI_UNALIGNED_LOAD32LE BrotliUnalignedRead32
388
- #define BROTLI_UNALIGNED_LOAD64LE BrotliUnalignedRead64
389
- #define BROTLI_UNALIGNED_STORE64LE BrotliUnalignedWrite64
390
- #elif BROTLI_BIG_ENDIAN /* BROTLI_LITTLE_ENDIAN */
391
- /* Explain compiler to byte-swap values. */
392
- #define BROTLI_BSWAP16_(V) ((uint16_t)( \
393
- (((V) & 0xFFU) << 8) | \
394
- (((V) >> 8) & 0xFFU)))
395
- static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) {
396
- uint16_t value = BrotliUnalignedRead16(p);
397
- return BROTLI_BSWAP16_(value);
398
- }
399
- #define BROTLI_BSWAP32_(V) ( \
400
- (((V) & 0xFFU) << 24) | (((V) & 0xFF00U) << 8) | \
401
- (((V) >> 8) & 0xFF00U) | (((V) >> 24) & 0xFFU))
402
- static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) {
403
- uint32_t value = BrotliUnalignedRead32(p);
404
- return BROTLI_BSWAP32_(value);
405
- }
406
- #define BROTLI_BSWAP64_(V) ( \
407
- (((V) & 0xFFU) << 56) | (((V) & 0xFF00U) << 40) | \
408
- (((V) & 0xFF0000U) << 24) | (((V) & 0xFF000000U) << 8) | \
409
- (((V) >> 8) & 0xFF000000U) | (((V) >> 24) & 0xFF0000U) | \
410
- (((V) >> 40) & 0xFF00U) | (((V) >> 56) & 0xFFU))
411
- static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) {
412
- uint64_t value = BrotliUnalignedRead64(p);
413
- return BROTLI_BSWAP64_(value);
414
- }
415
- static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) {
416
- uint64_t value = BROTLI_BSWAP64_(v);
417
- BrotliUnalignedWrite64(p, value);
418
- }
419
- #else /* BROTLI_LITTLE_ENDIAN */
420
- /* Read / store values byte-wise; hopefully compiler will understand. */
421
- static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) {
422
- const uint8_t* in = (const uint8_t*)p;
423
- return (uint16_t)(in[0] | (in[1] << 8));
424
- }
425
- static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) {
426
- const uint8_t* in = (const uint8_t*)p;
427
- uint32_t value = (uint32_t)(in[0]);
428
- value |= (uint32_t)(in[1]) << 8;
429
- value |= (uint32_t)(in[2]) << 16;
430
- value |= (uint32_t)(in[3]) << 24;
431
- return value;
432
- }
433
- static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) {
434
- const uint8_t* in = (const uint8_t*)p;
435
- uint64_t value = (uint64_t)(in[0]);
436
- value |= (uint64_t)(in[1]) << 8;
437
- value |= (uint64_t)(in[2]) << 16;
438
- value |= (uint64_t)(in[3]) << 24;
439
- value |= (uint64_t)(in[4]) << 32;
440
- value |= (uint64_t)(in[5]) << 40;
441
- value |= (uint64_t)(in[6]) << 48;
442
- value |= (uint64_t)(in[7]) << 56;
443
- return value;
444
- }
445
- static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) {
446
- uint8_t* out = (uint8_t*)p;
447
- out[0] = (uint8_t)v;
448
- out[1] = (uint8_t)(v >> 8);
449
- out[2] = (uint8_t)(v >> 16);
450
- out[3] = (uint8_t)(v >> 24);
451
- out[4] = (uint8_t)(v >> 32);
452
- out[5] = (uint8_t)(v >> 40);
453
- out[6] = (uint8_t)(v >> 48);
454
- out[7] = (uint8_t)(v >> 56);
455
- }
456
- #endif /* BROTLI_LITTLE_ENDIAN */
457
-
458
- /* BROTLI_IS_CONSTANT macros returns true for compile-time constants. */
459
- #if BROTLI_GNUC_HAS_BUILTIN(__builtin_constant_p, 3, 0, 1) || \
460
- BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
461
- #define BROTLI_IS_CONSTANT(x) (!!__builtin_constant_p(x))
462
- #else
463
- #define BROTLI_IS_CONSTANT(x) (!!0)
464
- #endif
465
-
466
- #if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY)
467
- #define BROTLI_HAS_UBFX (!!1)
468
- #else
469
- #define BROTLI_HAS_UBFX (!!0)
470
- #endif
471
-
472
- #if defined(BROTLI_ENABLE_LOG)
473
- #define BROTLI_LOG(x) printf x
474
- #else
475
- #define BROTLI_LOG(x)
476
- #endif
477
-
478
- #if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
479
- #define BROTLI_DCHECK(x) assert(x)
480
- static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) {
481
- fprintf(stderr, "%s:%d (%s)\n", f, l, fn);
482
- fflush(stderr);
483
- }
484
- #define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__)
485
- #else
486
- #define BROTLI_DCHECK(x)
487
- #define BROTLI_DUMP() (void)(0)
488
- #endif
489
-
490
- /* TODO: add appropriate icc/sunpro/arm/ibm/ti checks. */
491
- #if (BROTLI_GNUC_VERSION_CHECK(3, 0, 0) || defined(__llvm__)) && \
492
- !defined(BROTLI_BUILD_NO_RBIT)
493
- #if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY)
494
- /* TODO: detect ARMv6T2 and enable this code for it. */
495
- static BROTLI_INLINE brotli_reg_t BrotliRBit(brotli_reg_t input) {
496
- brotli_reg_t output;
497
- __asm__("rbit %0, %1\n" : "=r"(output) : "r"(input));
498
- return output;
499
- }
500
- #define BROTLI_RBIT(x) BrotliRBit(x)
501
- #endif /* armv7 / armv8 */
502
- #endif /* gcc || clang */
503
- #if !defined(BROTLI_RBIT)
504
- static BROTLI_INLINE void BrotliRBit(void) { /* Should break build if used. */ }
505
- #endif /* BROTLI_RBIT */
506
-
507
- #define BROTLI_REPEAT(N, X) { \
508
- if ((N & 1) != 0) {X;} \
509
- if ((N & 2) != 0) {X; X;} \
510
- if ((N & 4) != 0) {X; X; X; X;} \
511
- }
512
-
513
- #define BROTLI_UNUSED(X) (void)(X)
514
-
515
- #define BROTLI_MIN_MAX(T) \
516
- static BROTLI_INLINE T brotli_min_ ## T (T a, T b) { return a < b ? a : b; } \
517
- static BROTLI_INLINE T brotli_max_ ## T (T a, T b) { return a > b ? a : b; }
518
- BROTLI_MIN_MAX(double) BROTLI_MIN_MAX(float) BROTLI_MIN_MAX(int)
519
- BROTLI_MIN_MAX(size_t) BROTLI_MIN_MAX(uint32_t) BROTLI_MIN_MAX(uint8_t)
520
- #undef BROTLI_MIN_MAX
521
- #define BROTLI_MIN(T, A, B) (brotli_min_ ## T((A), (B)))
522
- #define BROTLI_MAX(T, A, B) (brotli_max_ ## T((A), (B)))
523
-
524
- #define BROTLI_SWAP(T, A, I, J) { \
525
- T __brotli_swap_tmp = (A)[(I)]; \
526
- (A)[(I)] = (A)[(J)]; \
527
- (A)[(J)] = __brotli_swap_tmp; \
528
- }
529
-
530
- #if BROTLI_64_BITS
531
- #if BROTLI_GNUC_HAS_BUILTIN(__builtin_ctzll, 3, 4, 0) || \
532
- BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
533
- #define BROTLI_TZCNT64 __builtin_ctzll
534
- #elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
535
- #if defined(BROTLI_TARGET_X64)
536
- #define BROTLI_TZCNT64 _tzcnt_u64
537
- #else /* BROTLI_TARGET_X64 */
538
- static BROTLI_INLINE uint32_t BrotliBsf64Msvc(uint64_t x) {
539
- uint32_t lsb;
540
- _BitScanForward64(&lsb, x);
541
- return lsb;
542
- }
543
- #define BROTLI_TZCNT64 BrotliBsf64Msvc
544
- #endif /* BROTLI_TARGET_X64 */
545
- #endif /* __builtin_ctzll */
546
- #endif /* BROTLI_64_BITS */
547
-
548
- #if BROTLI_GNUC_HAS_BUILTIN(__builtin_clz, 3, 4, 0) || \
549
- BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
550
- #define BROTLI_BSR32(x) (31u ^ (uint32_t)__builtin_clz(x))
551
- #elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
552
- static BROTLI_INLINE uint32_t BrotliBsr32Msvc(uint32_t x) {
553
- unsigned long msb;
554
- _BitScanReverse(&msb, x);
555
- return (uint32_t)msb;
556
- }
557
- #define BROTLI_BSR32 BrotliBsr32Msvc
558
- #endif /* __builtin_clz */
559
-
560
- /* Default brotli_alloc_func */
561
- BROTLI_COMMON_API void* BrotliDefaultAllocFunc(void* opaque, size_t size);
562
-
563
- /* Default brotli_free_func */
564
- BROTLI_COMMON_API void BrotliDefaultFreeFunc(void* opaque, void* address);
565
-
566
- BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) {
567
- BROTLI_UNUSED(&BrotliSuppressUnusedFunctions);
568
- BROTLI_UNUSED(&BrotliUnalignedRead16);
569
- BROTLI_UNUSED(&BrotliUnalignedRead32);
570
- BROTLI_UNUSED(&BrotliUnalignedRead64);
571
- BROTLI_UNUSED(&BrotliUnalignedWrite64);
572
- BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD16LE);
573
- BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD32LE);
574
- BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD64LE);
575
- BROTLI_UNUSED(&BROTLI_UNALIGNED_STORE64LE);
576
- BROTLI_UNUSED(&BrotliRBit);
577
- BROTLI_UNUSED(&brotli_min_double);
578
- BROTLI_UNUSED(&brotli_max_double);
579
- BROTLI_UNUSED(&brotli_min_float);
580
- BROTLI_UNUSED(&brotli_max_float);
581
- BROTLI_UNUSED(&brotli_min_int);
582
- BROTLI_UNUSED(&brotli_max_int);
583
- BROTLI_UNUSED(&brotli_min_size_t);
584
- BROTLI_UNUSED(&brotli_max_size_t);
585
- BROTLI_UNUSED(&brotli_min_uint32_t);
586
- BROTLI_UNUSED(&brotli_max_uint32_t);
587
- BROTLI_UNUSED(&brotli_min_uint8_t);
588
- BROTLI_UNUSED(&brotli_max_uint8_t);
589
- BROTLI_UNUSED(&BrotliDefaultAllocFunc);
590
- BROTLI_UNUSED(&BrotliDefaultFreeFunc);
591
- #if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
592
- BROTLI_UNUSED(&BrotliDump);
593
- #endif
594
- }
595
-
596
- #endif /* BROTLI_COMMON_PLATFORM_H_ */