Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\vsprintf.c Create Date:2022-07-28 06:11:58
Last Modify:2022-05-21 09:47:42 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Based on code by Douglas W. Jones found at* <http://www.cs.uiowa.edu/~jones/bcd/decimal.html#sixtyfour>* (with permission from the author).* Performs no 64-bit division and hence should be fast on 32-bit machines.

Proto:static char *put_dec(char *buf, unsigned long long n)

Type:char

Parameter:

TypeParameterName
char *buf
unsigned long longn
307  If n < 100 * 1000 * 1000 Then Return This will print a single '0' even if r == 0, since we would* immediately jump to out_r where two 0s would be written but only* one of them accounted for in buf. This is needed by ip4_string* below. All other callers pass a non-zero value of r.
310  d1 = n >> 16
311  h = n >> 32
312  d2 = h & 0xffff
313  d3 = h >> 16
317  q = 656 * d3 + 7296 * d2 + 5536 * d1 + (n & 0xffff)
318  q = Call put_dec_full4 on x % 10000, return x / 10000.* The approximation x/10000 == (x * 0x346DC5D7) >> 43* holds for all x < 1,128,869,999. The largest value this* helper will ever be asked to convert is 1,125,520,955.
320  q += 7671 * d3 + 9496 * d2 + 6 * d1
321  q = Call put_dec_full4 on x % 10000, return x / 10000.* The approximation x/10000 == (x * 0x346DC5D7) >> 43* holds for all x < 1,128,869,999. The largest value this* helper will ever be asked to convert is 1,125,520,955.
323  q += 4749 * d3 + 42 * d2
324  q = Call put_dec_full4 on x % 10000, return x / 10000.* The approximation x/10000 == (x * 0x346DC5D7) >> 43* holds for all x < 1,128,869,999. The largest value this* helper will ever be asked to convert is 1,125,520,955.
326  q += 281 * d3
327  buf += 12
328  If q Then buf = This will print a single '0' even if r == 0, since we would* immediately jump to out_r where two 0s would be written but only* one of them accounted for in buf. This is needed by ip4_string* below. All other callers pass a non-zero value of r.
330  Else When buf[ - 1] == '0' cycle
331  --buf
333  Return buf
Caller
NameDescribe
num_to_strConvert passed number to decimal string.* Returns the length of string. On buffer overflow, returns 0.* If speed is not important, use snprintf(). It's easy to read the code.
number