This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug in m68k memcpy/memcmp


Being that it is Friday, I have made a patch to temporarily remove memcpy.S and memset.S from being built until this can be resolved.

-- Jeff J.

Eric Norum wrote:
The proposed patch to the M68k versions of memcpy/memset has a nasty bug:


+.Lcopy: +#if !defined (__mcoldfire__) + dbra %d0,1b +#else + subq.l #1,%d0 + bpl 1b +#endif

The non-ColdFire version uses dbra -- which uses only the lower 16-bits of the counter register.
The above code will fail for transfers greater than 16*65535 bytes.


There needs to be another decrement of the most-significant 16-bits of the count register and another conditional branch and conditional branch added to all the 'dbra' loop tests.

Off the top of my head, I think that there needs to be something like:
+.Lcopy:
+#if !defined (__mcoldfire__)
+    dbra    %d0,1b
+      subl         #0x10000,d0
+     bpl           1b
+#else
+    subq.l    #1,%d0
+    bpl    1b
+#endif


--Eric Norum <norume@aps.anl.gov> Advanced Photon Source Argonne National Laboratory (630) 252-4793




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]