swh:1:snp:49cd9498d6cccc5e78252c27dcb645bcf7bf0c91
Raw File
Tip revision: f443e374ae131c168a065ea1748feac6b2e76613 authored by Linus Torvalds on 20 March 2022, 20:14:17 UTC
Linux 5.17
Tip revision: f443e37
lshrdi3.c
// SPDX-License-Identifier: GPL-2.0
#include "libgcc.h"

DWtype __lshrdi3(DWtype u, word_type b)
{
	const DWunion uu = {.ll = u};
	const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
	DWunion w;

	if (b == 0)
		return u;

	if (bm <= 0) {
		w.s.high = 0;
		w.s.low = (UWtype) uu.s.high >> -bm;
	} else {
		const UWtype carries = (UWtype) uu.s.high << bm;

		w.s.high = (UWtype) uu.s.high >> b;
		w.s.low = ((UWtype) uu.s.low >> b) | carries;
	}

	return w.ll;
}
back to top