- Performance of unaligned memory-accesses - 5 Updates
- Provably unprovable eliminates incompleteness - 1 Update
- Adding compilation arguments to 4000 make files. . . - 1 Update
David Brown <david.brown@hesbynett.no>: Aug 08 09:43PM +0200 On 08/08/2019 17:35, Bonita Montero wrote: > that the compiler usually won't see that an access is unaligned in mot > times so it can't be incompatible to this. So the whole thing is simply > defined by the architecture and not by the compiler. So it is all speculation and guesswork, with no evidence, documentation or recommendations to back up your position. And as compilers get better, and in particular as link-time optimisation (or "omniscient compilation") becomes more popular so that compilers /can/ see when accesses are aligned or not, the risk of things breaking gets higher. |
David Brown <david.brown@hesbynett.no>: Aug 08 09:45PM +0200 On 08/08/2019 17:38, Bonita Montero wrote: > And even more: compilers for those CPUs that support unaligned access > usually have special #pragma pack() or unaligned-directives. They won't > have these if they don't allow unaligned accesses. Compilers support unaligned accesses when using "pragma pack", "__unaligned", or other such features. Those features are documented to do the job. They exist /precisely/ because unaligned accesses are not allowed without them. The fact that compilers have this kind of extension shows that using normal pointers for unaligned access is not supported! |
scott@slp53.sl.home (Scott Lurndal): Aug 08 08:00PM >"__unaligned", or other such features. Those features are documented to >do the job. They exist /precisely/ because unaligned accesses are not >allowed without them. Or sometimes, they just support them: int main(void) { unsigned long a_variable = 0xaabbccddeeff0011ul; unsigned short *b_variable = (unsigned short *)((unsigned char *)&a_variable + 1); printf("addr=%p value=%x\n", b_variable, *b_variable); return 0; } $ cc -o /tmp/a /tmp/a.c /tmp/a.c: In function 'main': /tmp/a.c:9: warning: incompatible implicit declaration of built-in function 'printf' $ /tmp/a addr=0x7fff9644d151 value=ff00 >The fact that compilers have this kind of extension shows that using >normal pointers for unaligned access is not supported! Well sort of. |
Keith Thompson <kst-u@mib.org>: Aug 08 01:33PM -0700 > behaviour for the compiler you are using, and give hard compile-time > errors on compilers that don't support them. The code will not be as > portable, but you will avoid surprises with silent errors. The bug report I cited shows a case where "packed" gives *undefined* behavior by generating an invalid pointer without using pointer casts. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ |
David Brown <david.brown@hesbynett.no>: Aug 08 11:34PM +0200 On 08/08/2019 22:33, Keith Thompson wrote: >> portable, but you will avoid surprises with silent errors. > The bug report I cited shows a case where "packed" gives *undefined* > behavior by generating an invalid pointer without using pointer casts. I think you are asking for trouble by taking a pointer to a misaligned member of a packed struct. But it would better if the compiler told you this was a problem. I'd have preferred it to be an error (like taking the address of a member of a struct with the "scalar_storage_order" attribute for changing endianness), but a warning is OK. It took a long time to get this fixed, however - 7 years! |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Aug 08 09:28PM +0100 On 08/08/2019 18:15, peteolcott wrote: > on the basis that its satisfaction derives a contradiction. > Proof that Wittgenstein is correct about Gödel > https://www.researchgate.net/publication/333907915_Proof_that_Wittgenstein_is_correct_about_Godel Modulo the Sausage Conjecture of course. /Flibble -- "Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin "You won't burn in hell. But be nice anyway." – Ricky Gervais "I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
scott@slp53.sl.home (Scott Lurndal): Aug 08 07:56PM >> Makefiles in nested subdirectories. Altogether there's four thousand >> Makefiles. >Someone somewhere should be fired ... Why? Doesn't seem completely out-of-line: $ find bootloader firmware -name Makefile | wc -l 929 If you're also building linux: $ find linux -name Makefile | wc -l 2064 >> also the linker binary file, with a one-liner script like this: >> g++ -funwind-tables -rdynamic $* >> Any suggestions on how best to do this? I'd look at trying to tell make to use a modified default rule set, then you can have a rule like: %.o $(OBJDIR)/%.o: %.c @$(QUIET) || echo " COMPILE $<" $(HUSHCOMPILE)$(CC) $(CFLAGS) -funwind-tables -rdynamic -MMD -MP -o $@ -c $< %.o $(OBJDIR)/%.o: %.cpp @$(QUIET) || echo " COMPILE $<" $(HUSHCOMPILE)$(COMPILE.cpp) -funwind-tables -rdynamic -MMD -MP -o $@ $< I don't see anything in the man page that allows that with gmake, however. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment