RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 24-Jan-2011 16:37:57 Branch: rpm-5_4 Handle: 2011012415375600 Modified files: (Branch: rpm-5_4) rpm CHANGES rpm/rpmio lookup3.c Log: - simplify the lookup3.c valgrind logic. Summary: Revision Changes Path 1.3501.2.50 +1 -0 rpm/CHANGES 1.6.6.2 +16 -36 rpm/rpmio/lookup3.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.3501.2.49 -r1.3501.2.50 CHANGES --- rpm/CHANGES 13 Jan 2011 06:40:10 -0000 1.3501.2.49 +++ rpm/CHANGES 24 Jan 2011 15:37:56 -0000 1.3501.2.50 @@ -1,4 +1,5 @@ 5.4.0 -> 5.4.1: + - jbj: simplify the lookup3.c valgrind logic. - proyvind: rpmdb: set and create default log directory so that it doesn't get changed ie. when installing to a fresh chroot and no DB_CONFIG exists, with transaction logs ending up in a path that changes later. @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/lookup3.c ============================================================================ $ cvs diff -u -r1.6.6.1 -r1.6.6.2 lookup3.c --- rpm/rpmio/lookup3.c 8 Jan 2011 20:23:43 -0000 1.6.6.1 +++ rpm/rpmio/lookup3.c 24 Jan 2011 15:37:56 -0000 1.6.6.2 @@ -38,9 +38,8 @@ #include "rpmiotypes.h" #include "debug.h" +#undef UNLIKELY #ifdef WITH_VALGRIND -/* If we're using GCC, use __builtin_expect() to reduce overhead of - the valgrind checks */ #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) # define UNLIKELY(value) __builtin_expect((value), 0) && (value > 0 || (value = RUNNING_ON_VALGRIND)) #else @@ -266,9 +265,6 @@ u.ptr = key; if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) { const rpmuint32_t *k = (const rpmuint32_t *)key; /* read 32-bit chunks */ -#ifdef WITH_VALGRIND - const rpmuint8_t *k8; -#endif /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ while (size > 12) { @@ -291,10 +287,9 @@ * noticably faster for short strings (like English words). */ #ifdef WITH_VALGRIND - if(UNLIKELY(_running_on_valgrind)) { - /* make valgrind happy */ + if (UNLIKELY(_running_on_valgrind)) { + const rpmuint8_t * k8 = (const rpmuint8_t *)k; - k8 = (const rpmuint8_t *)k; switch (size) { case 12: c += k[2]; b+=k[1]; a+=k[0]; break; case 11: c += ((rpmuint32_t)k8[10])<<16; /*@fallthrough@*/ @@ -311,8 +306,9 @@ case 0: goto exit; } - } else { + } else #endif + { switch (size) { case 12: c += k[2]; b+=k[1]; a+=k[0]; break; case 11: c += k[2]&0xffffff; b+=k[1]; a+=k[0]; break; @@ -328,10 +324,7 @@ case 1: a += k[0]&0xff; break; case 0: goto exit; } -#ifdef WITH_VALGRIND - } -#endif /* !valgrind */ - + } } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { const rpmuint16_t *k = (const rpmuint16_t *)key; /* read 16-bit chunks */ const rpmuint8_t *k8; @@ -479,9 +472,6 @@ u.ptr = key; if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) { const rpmuint32_t *k = (const rpmuint32_t *)key; /* read 32-bit chunks */ -#ifdef WITH_VALGRIND - const rpmuint8_t *k8; -#endif /*-- all but last block: aligned reads and affect 32 bits of (a,b,c) */ while (size > 12) { @@ -503,10 +493,9 @@ * noticably faster for short strings (like English words). */ #ifdef WITH_VALGRIND - if(UNLIKELY(_running_on_valgrind)) { - /* make valgrind happy */ + if (UNLIKELY(_running_on_valgrind)) { + const rpmuint8_t * k8 = (const rpmuint8_t *)k; - k8 = (const rpmuint8_t *)k; switch (size) { case 12: c += k[2]; b+=k[1]; a+=k[0]; break; case 11: c += ((rpmuint32_t)k8[10])<<16; /*@fallthrough@*/ @@ -523,8 +512,9 @@ case 0: goto exit; } - } else { + } else #endif + { switch (size) { case 12: c += k[2]; b+=k[1]; a+=k[0]; break; case 11: c += k[2]&0xffffff; b+=k[1]; a+=k[0]; break; @@ -540,11 +530,7 @@ case 1: a += k[0]&0xff; break; case 0: goto exit; } - -#ifdef WITH_VALGRIND - } -#endif /* !valgrind */ - + } } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { const rpmuint16_t *k = (const rpmuint16_t *)key; /* read 16-bit chunks */ const rpmuint8_t *k8; @@ -686,9 +672,6 @@ u.ptr = key; if (HASH_BIG_ENDIAN && ((u.i & 0x3) == 0)) { const rpmuint32_t *k = (const rpmuint32_t *)key; /* read 32-bit chunks */ -#ifdef WITH_VALGRIND - const rpmuint8_t *k8; -#endif /*-- all but last block: aligned reads and affect 32 bits of (a,b,c) */ while (size > 12) { @@ -711,10 +694,9 @@ * noticably faster for short strings (like English words). */ #ifdef WITH_VALGRIND - if(UNLIKELY(_running_on_valgrind)) { - /* make valgrind happy */ + if (UNLIKELY(_running_on_valgrind)) { + const rpmuint8_t * k8 = (const rpmuint8_t *)k; - k8 = (const rpmuint8_t *)k; switch (size) { /* all the case statements fall through */ case 12: c += k[2]; b+=k[1]; a+=k[0]; break; case 11: c += ((rpmuint32_t)k8[10])<<8; /*@fallthrough@*/ @@ -731,8 +713,9 @@ case 0: goto exit; } - } else { + } else #endif + { switch (size) { case 12: c += k[2]; b+=k[1]; a+=k[0]; break; case 11: c += k[2]&0xffffff00; b+=k[1]; a+=k[0]; break; @@ -748,10 +731,7 @@ case 1: a += k[0]&0xff000000; break; case 0: goto exit; } -#ifdef WITH_VALGRIND - } -#endif /* !VALGRIND */ - + } } else { /* need to read the key one byte at a time */ const rpmuint8_t *k = (const rpmuint8_t *)key; @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org