Comments (3)
Additional Info:
lightning/external/libwally-core/src/ccan_config.h
has also same logic.
31 #if HAVE_UNALIGNED_ACCESS
32 #define alignment_ok(p, n) 1
33 #else
34 #define alignment_ok(p, n) ((size_t)(p) % (n) == 0)
35 #endif
Sould be the following?
31 #if HAVE_UNALIGNED_ACCESS
32 #define alignment_ok(p, n) ((size_t)(p) % (n) == 0)
33 #else
34 #define alignment_ok(p, n) 1
35 #endif
from ccan.
from ccan.
Thank you very much for your comment.
Sorry for late response.
Please forgive me what I can is leave some unorganized comments for now because this problem includes some composite and difficult issues.
HAVE_UNALIGNED_ACCESS=0 --> pointers are aligned appropriately in advance.
HAVE_UNALIGNED_ACCESS=1 --> pointers may not be aligned. need check and re-align.
No. HAVE_UNALIGNED_ACCESS=1 means you can access pointers with "unnatural" alignment. x86, for example, allows you to do this.
- Your answer is very useful information for me. Thanks again. Where is the detailed document about that kind of #define directives meaning and explanation?
- As you said, I know almost all x86 instructions allow “unnatural” alignment access except SIMD instructions. Some SIMD instructions, for instance,
movdqa
cannot unaligned access, if do it, raise exception. On the other hand,movdqu
can unaligned access. But it may slow down because it reads memory twice over the each aligned boundary. - In my opinion, just intuition, the existence of
HAVE_UNALIGNED_ACCESS
is “unnatural” coding because it expects and relies on a processor exact behavior too much. - I wonder why you allow “unnatural” alignment access even though your code is optimized very well. “unnatural” alignment access might slow down your code.
- I know some x86 series itself is optimized enough fast for unnatural alignment access. But too many series to support by software.
- I found ARM document about memory alignment and instructions. I hope it’s useful for you unless you have read it already.
How does the ARM Compiler support unaligned accesses? - What is the oldest compiler to support CCAN repository? I’d like to insert actively some kind of
__atribute__ ((aligned(x))
directives to the important pointers. Of caurse, CCAN can wrap that dicrectives by macro for compatibility.
Interestingly, my rPi thinks it can do it too, but perhaps unaligned
accesses actually trap, and it would perform better with this unset?
This is also my guess, it relates virtual memory allocates granularity, or, ARM processor’s failure. If the former, x86s allocates at least 4KB and didn’t touch non-commitment area by lucky. Anyway, As I told you at (3), to believe processor manufacturer’s document completely is sometimes risky in my opinion. I know Prof. Tanenbaum and David N. Cutler were consumed time by that kind of issues.
Current conclusion:
If I were you, when ARM processor detect by configure or make, I allocates alignment sensitive memory area by only aligned memory allocate functions. And, add __attribute__ ((aligned(x))
attributes to the all sensitive pointers. If target processor is x86(AMD), I don't change the result of processed code at all. I'll remove HAVE_UNALIGNED_ACCESS
macro (at least, statically).
I'm not sure for the other processors. (What's supported?)
Best Regards,
from ccan.
Related Issues (20)
- Strange content on the web site that does not seem to be present in github HOT 6
- What tool should I use to generate function documentation?
- base64 build errors on big endian BSD HOT 7
- Build assertion against conditions which cannot be evaluated.
- gcc13 error: '_170' may be used uninitialized HOT 1
- `tal_strdup(ctx, NULL)` returns uninitialized string
- `tal_strndup(ctx, NULL, 1)` breaks contract
- Non-conforming Isaac64 PRNG HOT 1
- SIGBUS on OpenBSD sparc64
- Spam URL on http://ccodearchive.net/ HOT 2
- multiple definition of `_asort' - on musl libc HOT 10
- endian compilation issues on Alpine Linux HOT 4
- JSON parser test failures HOT 1
- What does the licence name 'BSD-MIT' name? HOT 1
- JSON library doesn't work with locales that use comma as decimal separator
- bitmap doesn't work on 32bit x86/ARM HOT 2
- ccan: make check log from armv7l
- Requesting versioned snapshots HOT 7
- generator.h: Generators require coroutines HOT 3
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 ccan.