MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pmod

Function pmod

freebsd/netinet6/ip6_id.c:157–173  ·  view source on GitHub ↗

* Do a fast modular exponation, returned value will be in the range * of 0 - (mod-1) */

Source from the content-addressed store, hash-verified

155 * of 0 - (mod-1)
156 */
157static u_int32_t
158pmod(u_int32_t gen, u_int32_t expo, u_int32_t mod)
159{
160 u_int64_t s, t, u;
161
162 s = 1;
163 t = gen;
164 u = expo;
165
166 while (u) {
167 if (u & 1)
168 s = (s * t) % mod;
169 u >>= 1;
170 t = (t * t) % mod;
171 }
172 return (s);
173}
174
175/*
176 * Initializes the seed and chooses a suitable generator. Also toggles

Callers 2

initidFunction · 0.85
randomidFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected