| 1 | /* |
| 2 | * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | * accompanied this code). |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License version |
| 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | * or visit www.oracle.com if you need additional information or have any |
| 21 | * questions. |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * This file is available under and governed by the GNU General Public |
| 26 | * License version 2 only, as published by the Free Software Foundation. |
| 27 | * However, the following notice accompanied the original version of this |
| 28 | * file: |
| 29 | * |
| 30 | * (C) 2009 by Remo Dentato (rdentato@gmail.com) |
| 31 | * |
| 32 | * |
| 33 | * Redistribution and use in source and binary forms, with or without modification, |
| 34 | * are permitted provided that the following conditions are met: |
| 35 | * |
| 36 | * * Redistributions of source code must retain the above copyright notice, |
| 37 | * this list of conditions and the following disclaimer. |
| 38 | * * Redistributions in binary form must reproduce the above copyright notice, |
| 39 | * this list of conditions and the following disclaimer in the documentation |
| 40 | * and/or other materials provided with the distribution. |
| 41 | * |
| 42 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 43 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 44 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 45 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 46 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 47 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 48 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 49 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 50 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 51 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 52 | * |
| 53 | * http://opensource.org/licenses/bsd-license.php |
| 54 | */ |
| 55 | |
| 56 | #ifndef SHARE_GC_Z_ZHASH_INLINE_HPP |
| 57 | #define SHARE_GC_Z_ZHASH_INLINE_HPP |
| 58 | |
| 59 | #include "gc/z/zHash.hpp" |
| 60 | |
| 61 | inline uint32_t ZHash::uint32_to_uint32(uint32_t key) { |
| 62 | key = ~key + (key << 15); |
| 63 | key = key ^ (key >> 12); |
| 64 | key = key + (key << 2); |
| 65 | key = key ^ (key >> 4); |
| 66 | key = key * 2057; |
| 67 | key = key ^ (key >> 16); |
| 68 | return key; |
| 69 | } |
| 70 | |
| 71 | inline uint32_t ZHash::address_to_uint32(uintptr_t key) { |
| 72 | return uint32_to_uint32((uint32_t)(key >> 3)); |
| 73 | } |
| 74 | |
| 75 | #endif // SHARE_GC_Z_ZHASH_INLINE_HPP |
| 76 | |