xref: /kernel/linux/linux-5.10/lib/lshrdi3.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/lib/
18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * lib/lshrdi3.c
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/module.h>
78c2ecf20Sopenharmony_ci#include <linux/libgcc.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cilong long notrace __lshrdi3(long long u, word_type b)
108c2ecf20Sopenharmony_ci{
118c2ecf20Sopenharmony_ci	DWunion uu, w;
128c2ecf20Sopenharmony_ci	word_type bm;
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci	if (b == 0)
158c2ecf20Sopenharmony_ci		return u;
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci	uu.ll = u;
188c2ecf20Sopenharmony_ci	bm = 32 - b;
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci	if (bm <= 0) {
218c2ecf20Sopenharmony_ci		w.s.high = 0;
228c2ecf20Sopenharmony_ci		w.s.low = (unsigned int) uu.s.high >> -bm;
238c2ecf20Sopenharmony_ci	} else {
248c2ecf20Sopenharmony_ci		const unsigned int carries = (unsigned int) uu.s.high << bm;
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci		w.s.high = (unsigned int) uu.s.high >> b;
278c2ecf20Sopenharmony_ci		w.s.low = ((unsigned int) uu.s.low >> b) | carries;
288c2ecf20Sopenharmony_ci	}
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	return w.ll;
318c2ecf20Sopenharmony_ci}
328c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__lshrdi3);
33

Indexes created Thu Nov 07 10:32:03 CST 2024