tag:blogger.com,1999:blog-3993498847203183398.post5136953257599755852..comments2024-03-28T09:19:27.451+00:00Comments on RevK<sup>®</sup>'s ramblings: memcpy: Minor "D'uh" moment on my part, and warning to the wise.RevKhttp://www.blogger.com/profile/12369263214193333422noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-3993498847203183398.post-30149426514640137062011-02-04T16:47:00.217+00:002011-02-04T16:47:00.217+00:00Indeed, and I fully see the point of optimising me...Indeed, and I fully see the point of optimising memcpy in such ways - makes perfect sense.<br /><br />And no, I did not even blame the compiler or even start digging through the assembly code generated, I checked the manual first and went looking for a 2x4 to hit myself with.<br /><br />I am just really annoyed that, with many decades of experience, this early misunderstanding has stuck with me so long. Thankful such things are very rare.<br /><br />We learn something new every day.RevKhttps://www.blogger.com/profile/12369263214193333422noreply@blogger.comtag:blogger.com,1999:blog-3993498847203183398.post-36357380216552289062011-02-04T16:33:44.385+00:002011-02-04T16:33:44.385+00:00You are not alone - see https://bugzilla.redhat.co...You are not alone - see <a href="https://bugzilla.redhat.com/show_bug.cgi?id=638477" rel="nofollow">https://bugzilla.redhat.com/show_bug.cgi?id=638477</a>.<br /><br />As it happens, I was aware of this gotcha from a decidedly different perspective - I encountered an evil memcpy exploiting a feature of the (FPGA-based) memory controller to queue copies of entire pages (with optional offsets leaving blank space in the destination pages), and then go in and fill in the bits that couldn't be done by the memory controller.<br /><br />No ordering whatsoever in the memcpy, as the memory controller could (and did) reorder the copies to allow for DRAM banking and the like.Simon Farnsworthhttps://www.blogger.com/profile/15190608047563530091noreply@blogger.comtag:blogger.com,1999:blog-3993498847203183398.post-14925640917677428572011-02-04T15:57:31.640+00:002011-02-04T15:57:31.640+00:00I write/maintain a widely used C/C++ compiler for ...I write/maintain a widely used C/C++ compiler for a living, and yeah, memcpy is something we spend a lot of effort on optimising on each new platform we support (customers jump up and down a lot if we don't...). That can lead to all sorts of strange ways to copy :-)<br /><br />I also get to see some horrendous code sent our way when customers think our compiler doesn't generate the code they think it should... You are not alone!Chrishttps://www.blogger.com/profile/04504291065930945301noreply@blogger.comtag:blogger.com,1999:blog-3993498847203183398.post-71222488812668186442011-02-04T15:11:44.393+00:002011-02-04T15:11:44.393+00:00Don't doubt I considered that for a moment...
...Don't doubt I considered that for a moment...<br /><br />Hopefully I am not alone in this oversight - anyone else not realise it, do fess up to make me feel a bit better... :-)RevKhttps://www.blogger.com/profile/12369263214193333422noreply@blogger.comtag:blogger.com,1999:blog-3993498847203183398.post-87240827325154181572011-02-04T14:50:36.408+00:002011-02-04T14:50:36.408+00:00#define memcpy memmove
Done :p
(Note: I don'...#define memcpy memmove<br /><br />Done :p<br /><br />(Note: I don't actually advocate doing this, before the pedants start..)Anonymousnoreply@blogger.com