summaryrefslogtreecommitdiffstats
path: root/usr/klibc/libgcc/__lshrdi3.c
blob: 765e1f2c5d04e9254fc537a55a20495e2d4af1dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * libgcc/__lshrdi3.c
 */

#include <stdint.h>
#include <stddef.h>

uint64_t __lshrdi3(uint64_t v, int cnt)
{
	int c = cnt & 31;
	uint32_t vl = (uint32_t) v;
	uint32_t vh = (uint32_t) (v >> 32);

	if (cnt & 32) {
		vl = (vh >> c);
		vh = 0;
	} else {
		vl = (vl >> c) + (vh << (32 - c));
		vh = (vh >> c);
	}

	return ((uint64_t) vh << 32) + vl;
}