Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\mpi\mpih-div.c Create Date:2022-07-28 07:19:03
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Divide num (NP/NSIZE) by den (DP/DSIZE) and write* the NSIZE-DSIZE least significant quotient limbs at QP* and the DSIZE long remainder at NP. If QEXTRA_LIMBS is* non-zero, generate that many fraction bits and append them after the* other quotient limbs.

Proto:mpi_limb_t mpihelp_divrem(mpi_ptr_t qp, mpi_size_t qextra_limbs, mpi_ptr_t np, mpi_size_t nsize, mpi_ptr_t dp, mpi_size_t dsize)

Type:mpi_limb_t

Parameter:

TypeParameterName
mpi_ptr_tqp
mpi_size_tqextra_limbs
mpi_ptr_tnp
mpi_size_tnsize
mpi_ptr_tdp
mpi_size_tdsize
48  most_significant_q_limb = 0
51  Case dsize == 0
58  Return 1 / dsize
60  Case dsize == 1
66  d = dp[0]
67  n1 = np[nsize - 1]
69  If n1 >= d Then
70  n1 -= d
74  qp += qextra_limbs
75  When i >= 0 cycle udiv_qrnnd(qp[i], n1, n1, np[i], d)
77  qp -= qextra_limbs
79  When i >= 0 cycle udiv_qrnnd(qp[i], n1, n1, 0, d)
82  np[0] = n1
84  Break
86  Case dsize == 2
92  np += nsize - 2
93  d1 = dp[1]
94  d0 = dp[0]
95  n1 = np[1]
96  n0 = np[0]
98  If n1 >= d1 && ( n1 > d1 || n0 >= d0 ) Then
99  sub_ddmmss(n1, n0, n1, n0, d1, d0)
103  When i >= 0 cycle
107  If i >= qextra_limbs Then np--
109  Else np[0] = 0
112  If n1 == d1 Then
116  q = ~0
118  r = n0 + d1
119  If r < d1 Then
122  qp[i] = q
123  Continue
125  n1 = d0 - If d0 != 0 Then 1 Else 0
126  n0 = -d0
127  Else
128  udiv_qrnnd(q, r, n1, n0, d1)
129  umul_ppmm(n1, n0, d0, q)
132  n2 = np[0]
133  q_test :
134  If n1 > r || n1 == r && n0 > n2 Then
136  q--
137  sub_ddmmss(n1, n0, n1, n0, 0, d0)
138  r += d1
139  If r >= d1 Then Go to q_test
143  qp[i] = q
144  sub_ddmmss(n1, n0, r, n2, n1, n0)
146  np[1] = n1
147  np[0] = n0
149  Break
151  Default
156  np += nsize - dsize
157  dX = dp[dsize - 1]
158  d1 = dp[dsize - 2]
159  n0 = np[dsize - 1]
161  If n0 >= dX Then
164  mpihelp_sub_n(np, np, dp, dsize)
165  n0 = np[dsize - 1]
170  When i >= 0 cycle
175  If i >= qextra_limbs Then
176  np--
177  n2 = np[dsize]
178  Else
179  n2 = np[dsize - 1]
180  MPN_COPY_DECR(np + 1, np, dsize - 1)
181  np[0] = 0
184  If n0 == dX Then
187  q = ~0
188  Else
191  udiv_qrnnd(q, r, n0, np[dsize - 1], dX)
192  umul_ppmm(n1, n0, d1, q)
194  When n1 > r || n1 == r && n0 > np[dsize - 2] cycle
197  q--
198  r += dX
199  If r < dX Then Break
201  n1 -= n0 < d1
202  n0 -= d1
211  If n2 != cy_limb Then
212  mpihelp_add_n(np, np, dp, dsize)
213  q--
216  qp[i] = q
217  n0 = np[dsize - 1]
222  Return most_significant_q_limb
Caller
NameDescribe
mpi_powmRES = BASE ^ EXP mod MOD