lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 25 Apr 2012 15:29:36 +0100
From:	Jay Foad <jay.foad@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [PATCH 1/2] math128: Introduce {mult,add,cmp}_u128

> +#ifndef shl_u128
> +static inline u128 shl_u128(u128 x, unsigned int n)
> +{
> +	u128 res;
> +
> +	if (n < 64) {
> +		res.hi = x.hi << n;
> +		res.hi |= x.lo >> (64 - n);

This is undefined when n == 0.

> +		res.lo = x.lo << n;
> +	} else {
> +		res.lo = 0;
> +		res.hi = x.lo << (n - 64);
> +	}
> +
> +	return res;
> +}
> +#endif /* shl_u128 */
> +
> +#ifndef shr_u128
> +static inline u128 shr_u128(u128 x, unsigned int n)
> +{
> +	u128 res;
> +
> +	if (n < 64) {
> +		res.lo = x.lo >> n;
> +		res.lo |= x.hi << (64 - n);

Likewise.

> +		res.hi = x.hi >> n;
> +	} else {
> +		res.hi = 0;
> +		res.lo = x.hi >> (n - 64);
> +	}
> +
> +	return res;
> +}
> +#endif /* shr_u128 */

Jay.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ