equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
217 // Borrowed almost verbatim from Hacker's Delight by Henry S. Warren, Jr. with |
217 // Borrowed almost verbatim from Hacker's Delight by Henry S. Warren, Jr. with |
218 // minor type name and parameter changes. Adjusted to 64 bit word width. |
218 // minor type name and parameter changes. Adjusted to 64 bit word width. |
219 static bool magic_long_divide_constants(jlong d, jlong &M, jint &s) { |
219 static bool magic_long_divide_constants(jlong d, jlong &M, jint &s) { |
220 int64_t p; |
220 int64_t p; |
221 uint64_t ad, anc, delta, q1, r1, q2, r2, t; |
221 uint64_t ad, anc, delta, q1, r1, q2, r2, t; |
222 const uint64_t two63 = 0x8000000000000000LL; // 2**63. |
222 const uint64_t two63 = UCONST64(0x8000000000000000); // 2**63. |
223 |
223 |
224 ad = ABS(d); |
224 ad = ABS(d); |
225 if (d == 0 || d == 1) return false; |
225 if (d == 0 || d == 1) return false; |
226 t = two63 + ((uint64_t)d >> 63); |
226 t = two63 + ((uint64_t)d >> 63); |
227 anc = t - 1 - t%ad; // Absolute value of nc. |
227 anc = t - 1 - t%ad; // Absolute value of nc. |