Comments (6)
Probably related (warnings from clang):
/home/nemequ/local/src/squash/plugins/brotli/brotli/dec/./bit_reader.h:151:8: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint64_t *'
(aka 'unsigned long *') increases required alignment from 1 to 8 [-Werror,-Wcast-align]
*(uint64_t*)(dst + bytes_read) = 0;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/nemequ/local/src/squash/plugins/brotli/brotli/dec/./bit_reader.h:152:8: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint64_t *'
(aka 'unsigned long *') increases required alignment from 1 to 8 [-Werror,-Wcast-align]
*(uint64_t*)(dst + bytes_read + 8) = 0;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/nemequ/local/src/squash/plugins/brotli/brotli/dec/./bit_reader.h:153:8: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint64_t *'
(aka 'unsigned long *') increases required alignment from 1 to 8 [-Werror,-Wcast-align]
*(uint64_t*)(dst + bytes_read + 16) = 0;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/nemequ/local/src/squash/plugins/brotli/brotli/dec/./bit_reader.h:154:8: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint64_t *'
(aka 'unsigned long *') increases required alignment from 1 to 8 [-Werror,-Wcast-align]
*(uint64_t*)(dst + bytes_read + 24) = 0;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/nemequ/local/src/squash/plugins/brotli/brotli/dec/./bit_reader.h:189:30: error: cast from 'uint8_t *' (aka 'unsigned char *') to
'const uint32_t *' (aka 'const unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
br->val_ |= ((uint64_t)(*(const uint32_t*)(
^~~~~~~~~~~~~~~~~~
from brotli.
Unaligned loads/stores in bit_reader are intentional. We carefully profiled and decided to use them for better performance.
I'm going to take a look at overflow/shifting issues soon.
from brotli.
FWIW at least clang and, to a lesser extent, gcc are pretty good about generating fast code for memcpy with fixed sizes. Newer versions of GCC are better, but still not optimal. It might be worth it to keep an eye on that GCC bug and revisit the issue once it is resolved… unaligned accesses can cause problems down the road when the CC starts optimizing things better (this happened to LZ4 recently).
from brotli.
Unaligned loads/stores: the "official"/safe way to do an unaligned 32-bit load from "p" is:
uint32_t tmp;
memcpy(&tmp, p, sizeof(uint32_t));
// use tmp
Store likewise via memcpy. I know this is really gross, but I've run into several compilers that get really aggressive about assuming that loads/stores are aligned, and all major C/C++ compilers actually detect this type of use of memcpy and turn it into the unaligned loads/stores you want. I would prefer not to have to do this kind of thing, but compilers tend to get more pedantic about spec-lawyering all the time, and especially ARM compilers like to combine adjacent LDRs (which do not require alignment on ARMv6+) into LDRDs (which do), which has caused "fun" portability problems for me in the past.
from brotli.
We're going to make unaligned safer and more portable soon. So, stay tuned.
from brotli.
Fixed with PR 183.
Compiling with -DBROTLI_BUILD_PORTABLE avoids overlapping memcpy and unaligned reads.
from brotli.
Related Issues (20)
- Release v1.1 HOT 14
- Publish JNI artefacts (including platform-dependent) HOT 7
- Stale comment referring to nonexisting WriteMetadata() function HOT 6
- v1.1.0rc does not build on macOS 10.12.6 HOT 8
- Strange compression ratio on large CSV file... HOT 1
- Brotli v1.1.0 tests fail with pypy3 HOT 10
- Brotli 1.1.0 breaks Python 2 compatibility HOT 3
- Create a static source tarball for releases
- CMake build broken, tries to install man files in /man not in CMAKE_INSTALL_PREFIX
- bazel error no such package '@org_brotli// HOT 4
- Brotli 1.1.0 NginX HOT 3
- Brotli 1.1.0 changed return values? HOT 5
- [Feature Request] adding a option to control whether install the executable HOT 4
- makefile broken HOT 7
- undefined symbol BrotliEncoderDestroyPreparedDictionary HOT 5
- Windows ARM64EC Target Fails - _tzcnt_u64(EC Symbol) HOT 4
- CMake compile error on Debian bookworm HOT 1
- 1.0.9 used to build static libraries - where have they gone?
- Kotlin Multiplatform HOT 11
- AMD gpu brotli sdk 1.0 > inclusion? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brotli.