]> git.pld-linux.org Git - packages/liboil.git/commitdiff
- so much unaligned write access doesn't seem like a good idea
authorsparky <sparky@pld-linux.org>
Sun, 3 May 2009 01:53:37 +0000 (01:53 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    liboil-fixes.patch -> 1.5

liboil-fixes.patch

index 63f25787397ce97f42913e6966feaadec83ee203..6192331fc4dd337cde047811207bd6c63edf12cf 100644 (file)
  
        dest[i] = atmp[0];
        if (i+1<n) dest[i+1] = atmp[1];
+--- liboil-0.3.16/liboil/copy/splat_ref.c      2007-11-16 03:53:47.000000000 +0100
++++ liboil-0.3.16.fix/liboil/copy/splat_ref.c  2009-05-03 03:37:00.000000000 +0200
+@@ -101,18 +101,40 @@
+ #ifdef HAVE_UNALIGNED_ACCESS
+ static void splat_u8_ns_int (uint8_t *dest, const uint8_t *param, int n)
+ {
+-  int p;
+-  while(n&3) {
+-    *dest = *param;
+-    dest++;
+-    n--;
++  int i;
++  uint32_t p, *dest32;
++  size_t diff;
++
++  if(n<4) {
++    for ( i=0; i<n; i++) {
++      dest[i] = *param;
++    }
++    return;
+   }
+-  n >>= 2;
++
+   p = (*param<<24) | (*param<<16) | (*param<<8) | (*param);
+-  while(n>0){
+-    *(uint32_t *)dest = p;
+-    dest+=4;
+-    n--;
++
++  dest32 = (void *)dest;
++  dest32[0] = p; /* may be unaligned */
++
++  /* align */
++  dest32 += 1;
++  dest32 = (void *)( ((uintptr_t)dest32) & (~3) );
++  diff = (void *)dest32 - (void *)dest;
++
++  n -= diff;
++  diff = n & 3;
++  n >>= 2;
++  /* aligned copy */
++  for( i=0; i<n; i++) {
++    dest32[i] = p;
++  }
++  dest32 += n;
++
++  /* unaligned */
++  if ( diff ) {
++    dest32 = (void *) ((uintptr_t)dest32 + diff - 4);
++    dest32[0] = p;
+   }
+ }
+ OIL_DEFINE_IMPL(splat_u8_ns_int, splat_u8_ns);
This page took 0.090652 seconds and 4 git commands to generate.