Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * lib/lshrdi3.c
0004  */
0005 
0006 #include <linux/module.h>
0007 #include <linux/libgcc.h>
0008 
0009 long long notrace __lshrdi3(long long u, word_type b)
0010 {
0011     DWunion uu, w;
0012     word_type bm;
0013 
0014     if (b == 0)
0015         return u;
0016 
0017     uu.ll = u;
0018     bm = 32 - b;
0019 
0020     if (bm <= 0) {
0021         w.s.high = 0;
0022         w.s.low = (unsigned int) uu.s.high >> -bm;
0023     } else {
0024         const unsigned int carries = (unsigned int) uu.s.high << bm;
0025 
0026         w.s.high = (unsigned int) uu.s.high >> b;
0027         w.s.low = ((unsigned int) uu.s.low >> b) | carries;
0028     }
0029 
0030     return w.ll;
0031 }
0032 EXPORT_SYMBOL(__lshrdi3);