2N/A/*
2N/A * Copyright (c) 1992, 1993
2N/A * The Regents of the University of California. All rights reserved.
2N/A *
2N/A * This software was developed by the Computer Systems Engineering group
2N/A * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
2N/A * contributed to Berkeley.
2N/A *
2N/A * Redistribution and use in source and binary forms, with or without
2N/A * modification, are permitted provided that the following conditions
2N/A * are met:
2N/A * 1. Redistributions of source code must retain the above copyright
2N/A * notice, this list of conditions and the following disclaimer.
2N/A * 2. Redistributions in binary form must reproduce the above copyright
2N/A * notice, this list of conditions and the following disclaimer in the
2N/A * documentation and/or other materials provided with the distribution.
2N/A * 4. Neither the name of the University nor the names of its contributors
2N/A * may be used to endorse or promote products derived from this software
2N/A * without specific prior written permission.
2N/A *
2N/A * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2N/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2N/A * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2N/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2N/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2N/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2N/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2N/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2N/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2N/A * SUCH DAMAGE.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#include "quadint.h"
2N/A
2N/A#pragma weak __ashrdi3 = ___ashrdi3
2N/A
2N/A/*
2N/A * Shift a (signed) quad value right (arithmetic shift right).
2N/A */
2N/Alonglong_t
2N/A___ashrdi3(longlong_t a, qshift_t shift)
2N/A{
2N/A union uu aa;
2N/A
2N/A aa.q = a;
2N/A if (shift >= LONG_BITS) {
2N/A long s;
2N/A
2N/A /*
2N/A * Smear bits rightward using the machine's right-shift
2N/A * method, whether that is sign extension or zero fill,
2N/A * to get the `sign word' s. Note that shifting by
2N/A * LONG_BITS is undefined, so we shift (LONG_BITS-1),
2N/A * then 1 more, to get our answer.
2N/A */
2N/A s = (aa.sl[H] >> (LONG_BITS - 1)) >> 1;
2N/A aa.ul[L] = shift >= QUAD_BITS ? s :
2N/A aa.sl[H] >> (shift - LONG_BITS);
2N/A aa.ul[H] = s;
2N/A } else if (shift > 0) {
2N/A aa.ul[L] = (aa.ul[L] >> shift) |
2N/A (aa.ul[H] << (LONG_BITS - shift));
2N/A aa.sl[H] >>= shift;
2N/A }
2N/A return (aa.q);
2N/A}