X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libhashkit%2Fjenkins.cc;h=2001cab47cc7b6192f69e4b103d763b51a3b3b23;hb=dbc62573e1a6dc8cbcc97d0898e8615b0916d6ab;hp=5f85ad62a220c5b04f0708c5f37776c1e2155ad7;hpb=0a03ebf8bb9cce372fb4ffa6bd6648082dbc0da3;p=awesomized%2Flibmemcached diff --git a/libhashkit/jenkins.cc b/libhashkit/jenkins.cc index 5f85ad62..2001cab4 100644 --- a/libhashkit/jenkins.cc +++ b/libhashkit/jenkins.cc @@ -1,3 +1,40 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * HashKit library + * + * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + /* * * By Bob Jenkins, 2006. bob_jenkins@burtleburtle.net. You may use this @@ -59,12 +96,14 @@ In which case, the hash table should have hashsize(10) elements. uint32_t hashkit_jenkins(const char *key, size_t length, void *) { uint32_t a,b,c; /* internal state */ - union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */ +#ifndef WORDS_BIGENDIAN + union { const void *ptr; size_t i; } u; + u.ptr = key; +#endif /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)length) + JENKINS_INITVAL; - u.ptr = key; #ifndef WORDS_BIGENDIAN if ((u.i & 0x3) == 0) {