ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libecb/ecb.pod
(Generate patch)

Comparing libecb/ecb.pod (file contents):
Revision 1.91 by root, Tue Jun 22 01:07:29 2021 UTC vs.
Revision 1.92 by sf-exg, Tue Jun 22 05:28:44 2021 UTC

168 168
169=item ECB_64BIT_NATIVE 169=item ECB_64BIT_NATIVE
170 170
171Evaluates to a true value (suitable for both preprocessor and C code 171Evaluates to a true value (suitable for both preprocessor and C code
172testing) if 64 bit integer types on this architecture are evaluated 172testing) if 64 bit integer types on this architecture are evaluated
173"natively", that is, with similar speeds as 32 bit integerss. While 64 bit 173"natively", that is, with similar speeds as 32 bit integers. While 64 bit
174integer support is very common (and in fatc required by libecb), 32 bit 174integer support is very common (and in fact required by libecb), 32 bit
175cpus have to emulate operations on them, so you might want to avoid them. 175cpus have to emulate operations on them, so you might want to avoid them.
176 176
177=item ECB_AMD64, ECB_AMD64_X32 177=item ECB_AMD64, ECB_AMD64_X32
178 178
179These two macros are defined to C<1> on the x86_64/amd64 ABI and the X32 179These two macros are defined to C<1> on the x86_64/amd64 ABI and the X32
950=item char *ecb_i2a_u32 (char *ptr, uint32_t value) 950=item char *ecb_i2a_u32 (char *ptr, uint32_t value)
951 951
952Takes an C<uint32_t> I<value> and formats it as a decimal number starting 952Takes an C<uint32_t> I<value> and formats it as a decimal number starting
953at I<ptr>, using at most C<ECB_I2A_I32_DIGITS> characters. Returns a 953at I<ptr>, using at most C<ECB_I2A_I32_DIGITS> characters. Returns a
954pointer to just after the generated string, where you would normally put 954pointer to just after the generated string, where you would normally put
955the temrinating C<0> character. This function outputs the minimum number 955the terminating C<0> character. This function outputs the minimum number
956of digits. 956of digits.
957 957
958=item ECB_I2A_U32_DIGITS (=10) 958=item ECB_I2A_U32_DIGITS (=10)
959 959
960=item char *ecb_i2a_i32 (char *ptr, int32_t value) 960=item char *ecb_i2a_i32 (char *ptr, int32_t value)
980=back 980=back
981 981
982=head3 LOW-LEVEL API 982=head3 LOW-LEVEL API
983 983
984The functions above use a number of low-level APIs which have some strict 984The functions above use a number of low-level APIs which have some strict
985limitaitons, but cna be used as building blocks (study of C<ecb_i2a_i32> 985limitations, but can be used as building blocks (study of C<ecb_i2a_i32>
986and related cunctions is recommended). 986and related functions is recommended).
987 987
988There are three families of functions: functions that convert a number 988There are three families of functions: functions that convert a number
989to a fixed number of digits with leading zeroes (C<ecb_i2a_0N>, C<0> 989to a fixed number of digits with leading zeroes (C<ecb_i2a_0N>, C<0>
990for "leading zeroes"), functions that generate up to N digits, skipping 990for "leading zeroes"), functions that generate up to N digits, skipping
991leading zeroes (C<_N>), and functions that can generate more digits, but 991leading zeroes (C<_N>), and functions that can generate more digits, but
992the leading digit has limited range (C<_xN>). 992the leading digit has limited range (C<_xN>).
993 993
994None of the functions deal with negative numbera. 994None of the functions deal with negative numbers.
995 995
996Example: convert an IP address in an u32 into dotted-quad: 996Example: convert an IP address in an u32 into dotted-quad:
997 997
998 uint32_t ip = 0x0a000164; // 10.0.1.100 998 uint32_t ip = 0x0a000164; // 10.0.1.100
999 char ips[3 * 4 + 3 + 1]; 999 char ips[3 * 4 + 3 + 1];
1062functions, but they can generate one digit more, as long as the number 1062functions, but they can generate one digit more, as long as the number
1063is within range, which is given by the symbols C<ECB_I2A_MAX_X5> (almost 1063is within range, which is given by the symbols C<ECB_I2A_MAX_X5> (almost
106416 bit range) and C<ECB_I2A_MAX_X10> (a bit more than 31 bit range), 106416 bit range) and C<ECB_I2A_MAX_X10> (a bit more than 31 bit range),
1065respectively. 1065respectively.
1066 1066
1067For example, the sigit part of a 32 bit signed integer just fits into the 1067For example, the digit part of a 32 bit signed integer just fits into the
1068C<ECB_I2A_MAX_X10> range, so while C<ecb_i2a_x10> cannot convert a 10 1068C<ECB_I2A_MAX_X10> range, so while C<ecb_i2a_x10> cannot convert a 10
1069digit number, it can convert all 32 bit signed numbers. Sadly, it's not 1069digit number, it can convert all 32 bit signed numbers. Sadly, it's not
1070good enough for 32 bit unsigned numbers. 1070good enough for 32 bit unsigned numbers.
1071 1071
1072=back 1072=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines