162306a36Sopenharmony_ci/* ashrdi3.c extracted from gcc-2.95.2/libgcc2.c which is: */ 262306a36Sopenharmony_ci/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc. 362306a36Sopenharmony_ci 462306a36Sopenharmony_ciThis file is part of GNU CC. 562306a36Sopenharmony_ci 662306a36Sopenharmony_ciGNU CC is free software; you can redistribute it and/or modify 762306a36Sopenharmony_ciit under the terms of the GNU General Public License as published by 862306a36Sopenharmony_cithe Free Software Foundation; either version 2, or (at your option) 962306a36Sopenharmony_ciany later version. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ciGNU CC is distributed in the hope that it will be useful, 1262306a36Sopenharmony_cibut WITHOUT ANY WARRANTY; without even the implied warranty of 1362306a36Sopenharmony_ciMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1462306a36Sopenharmony_ciGNU General Public License for more details. */ 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#include <linux/compiler.h> 1762306a36Sopenharmony_ci#include <linux/export.h> 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define BITS_PER_UNIT 8 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_citypedef int SItype __mode(SI); 2262306a36Sopenharmony_citypedef unsigned int USItype __mode(SI); 2362306a36Sopenharmony_citypedef int DItype __mode(DI); 2462306a36Sopenharmony_citypedef int word_type __mode(__word__); 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cistruct DIstruct {SItype high, low;}; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_citypedef union 2962306a36Sopenharmony_ci{ 3062306a36Sopenharmony_ci struct DIstruct s; 3162306a36Sopenharmony_ci DItype ll; 3262306a36Sopenharmony_ci} DIunion; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ciDItype 3562306a36Sopenharmony_ci__ashldi3 (DItype u, word_type b) 3662306a36Sopenharmony_ci{ 3762306a36Sopenharmony_ci DIunion w; 3862306a36Sopenharmony_ci word_type bm; 3962306a36Sopenharmony_ci DIunion uu; 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci if (b == 0) 4262306a36Sopenharmony_ci return u; 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci uu.ll = u; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci bm = (sizeof (SItype) * BITS_PER_UNIT) - b; 4762306a36Sopenharmony_ci if (bm <= 0) 4862306a36Sopenharmony_ci { 4962306a36Sopenharmony_ci w.s.low = 0; 5062306a36Sopenharmony_ci w.s.high = (USItype)uu.s.low << -bm; 5162306a36Sopenharmony_ci } 5262306a36Sopenharmony_ci else 5362306a36Sopenharmony_ci { 5462306a36Sopenharmony_ci USItype carries = (USItype)uu.s.low >> bm; 5562306a36Sopenharmony_ci w.s.low = (USItype)uu.s.low << b; 5662306a36Sopenharmony_ci w.s.high = ((USItype)uu.s.high << b) | carries; 5762306a36Sopenharmony_ci } 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci return w.ll; 6062306a36Sopenharmony_ci} 6162306a36Sopenharmony_ciEXPORT_SYMBOL(__ashldi3); 62