Lines Matching +full:per +full:- +full:string
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
4 * Module Name: utstrsuppt - Support functions for string-to-integer conversion
27 * PARAMETERS: string - Null terminated input string
28 * return_value_ptr - Where the converted value is returned
30 * RETURN: Status and 64-bit converted integer
32 * DESCRIPTION: Performs a base 8 conversion of the input string to an
35 * NOTE: Maximum 64-bit unsigned octal value is 01777777777777777777777
36 * Maximum 32-bit unsigned octal value is 037777777777
40 acpi_status acpi_ut_convert_octal_string(char *string, u64 *return_value_ptr) in acpi_ut_convert_octal_string() argument
45 /* Convert each ASCII byte in the input string */ in acpi_ut_convert_octal_string()
47 while (*string) { in acpi_ut_convert_octal_string()
49 * Character must be ASCII 0-7, otherwise: in acpi_ut_convert_octal_string()
50 * 1) Runtime: terminate with no error, per the ACPI spec in acpi_ut_convert_octal_string()
53 if (!(ACPI_IS_OCTAL_DIGIT(*string))) { in acpi_ut_convert_octal_string()
62 status = acpi_ut_insert_digit(&accumulated_value, 8, *string); in acpi_ut_convert_octal_string()
68 string++; in acpi_ut_convert_octal_string()
81 * PARAMETERS: string - Null terminated input string
82 * return_value_ptr - Where the converted value is returned
84 * RETURN: Status and 64-bit converted integer
86 * DESCRIPTION: Performs a base 10 conversion of the input string to an
89 * NOTE: Maximum 64-bit unsigned decimal value is 18446744073709551615
90 * Maximum 32-bit unsigned decimal value is 4294967295
94 acpi_status acpi_ut_convert_decimal_string(char *string, u64 *return_value_ptr) in acpi_ut_convert_decimal_string() argument
99 /* Convert each ASCII byte in the input string */ in acpi_ut_convert_decimal_string()
101 while (*string) { in acpi_ut_convert_decimal_string()
103 * Character must be ASCII 0-9, otherwise: in acpi_ut_convert_decimal_string()
104 * 1) Runtime: terminate with no error, per the ACPI spec in acpi_ut_convert_decimal_string()
107 if (!isdigit((int)*string)) { in acpi_ut_convert_decimal_string()
116 status = acpi_ut_insert_digit(&accumulated_value, 10, *string); in acpi_ut_convert_decimal_string()
122 string++; in acpi_ut_convert_decimal_string()
135 * PARAMETERS: string - Null terminated input string
136 * return_value_ptr - Where the converted value is returned
138 * RETURN: Status and 64-bit converted integer
140 * DESCRIPTION: Performs a base 16 conversion of the input string to an
143 * NOTE: Maximum 64-bit unsigned hex value is 0xFFFFFFFFFFFFFFFF
144 * Maximum 32-bit unsigned hex value is 0xFFFFFFFF
148 acpi_status acpi_ut_convert_hex_string(char *string, u64 *return_value_ptr) in acpi_ut_convert_hex_string() argument
153 /* Convert each ASCII byte in the input string */ in acpi_ut_convert_hex_string()
155 while (*string) { in acpi_ut_convert_hex_string()
157 * Character must be ASCII A-F, a-f, or 0-9, otherwise: in acpi_ut_convert_hex_string()
158 * 1) Runtime: terminate with no error, per the ACPI spec in acpi_ut_convert_hex_string()
161 if (!isxdigit((int)*string)) { in acpi_ut_convert_hex_string()
170 status = acpi_ut_insert_digit(&accumulated_value, 16, *string); in acpi_ut_convert_hex_string()
176 string++; in acpi_ut_convert_hex_string()
189 * PARAMETERS: string - Pointer to input ASCII string
192 * used by the caller to detect end-of-string.
194 * DESCRIPTION: Remove any leading zeros in the input string. Return the
196 * to check for the end of the string (NULL terminator).
200 char acpi_ut_remove_leading_zeros(char **string) in acpi_ut_remove_leading_zeros() argument
203 while (**string == ACPI_ASCII_ZERO) { in acpi_ut_remove_leading_zeros()
204 *string += 1; in acpi_ut_remove_leading_zeros()
207 return (**string); in acpi_ut_remove_leading_zeros()
214 * PARAMETERS: string - Pointer to input ASCII string
217 * used by the caller to detect end-of-string.
219 * DESCRIPTION: Remove any leading whitespace in the input string. Return the
221 * to check for the end of the string (NULL terminator).
225 char acpi_ut_remove_whitespace(char **string) in acpi_ut_remove_whitespace() argument
228 while (isspace((u8)**string)) { in acpi_ut_remove_whitespace()
229 *string += 1; in acpi_ut_remove_whitespace()
232 return (**string); in acpi_ut_remove_whitespace()
239 * PARAMETERS: string - Pointer to input ASCII string
241 * RETURN: TRUE if a "0x" prefix was found at the start of the string
247 u8 acpi_ut_detect_hex_prefix(char **string) in acpi_ut_detect_hex_prefix() argument
249 char *initial_position = *string; in acpi_ut_detect_hex_prefix()
251 acpi_ut_remove_hex_prefix(string); in acpi_ut_detect_hex_prefix()
252 if (*string != initial_position) { in acpi_ut_detect_hex_prefix()
253 return (TRUE); /* String is past leading 0x */ in acpi_ut_detect_hex_prefix()
256 return (FALSE); /* Not a hex string */ in acpi_ut_detect_hex_prefix()
263 * PARAMETERS: string - Pointer to input ASCII string
271 void acpi_ut_remove_hex_prefix(char **string) in acpi_ut_remove_hex_prefix() argument
273 if ((**string == ACPI_ASCII_ZERO) && in acpi_ut_remove_hex_prefix()
274 (tolower((int)*(*string + 1)) == 'x')) { in acpi_ut_remove_hex_prefix()
275 *string += 2; /* Go past the leading 0x */ in acpi_ut_remove_hex_prefix()
283 * PARAMETERS: string - Pointer to input ASCII string
286 * string
292 u8 acpi_ut_detect_octal_prefix(char **string) in acpi_ut_detect_octal_prefix() argument
295 if (**string == ACPI_ASCII_ZERO) { in acpi_ut_detect_octal_prefix()
296 *string += 1; /* Go past the leading 0 */ in acpi_ut_detect_octal_prefix()
300 return (FALSE); /* Not an octal string */ in acpi_ut_detect_octal_prefix()
307 * PARAMETERS: accumulated_value - Current value of the integer value
310 * base - Radix, either 8/10/16
311 * ascii_digit - ASCII single digit to be inserted
357 * PARAMETERS: multiplicand - Current accumulated converted integer
358 * base - Base/Radix
359 * out_product - Where the product is returned
361 * RETURN: Status and 64-bit product
363 * DESCRIPTION: Multiply two 64-bit values, with checking for 64-bit overflow as
364 * well as 32-bit overflow if necessary (if the current global
383 * Check for 64-bit overflow before the actual multiplication. in acpi_ut_strtoul_multiply64()
385 * Notes: 64-bit division is often not supported on 32-bit platforms in acpi_ut_strtoul_multiply64()
387 * 64-bit divide function. Also, Multiplier is currently only used in acpi_ut_strtoul_multiply64()
397 /* Check for 32-bit overflow if necessary */ in acpi_ut_strtoul_multiply64()
411 * PARAMETERS: addend1 - Current accumulated converted integer
412 * digit - New hex value/char
413 * out_sum - Where sum is returned (Accumulator)
415 * RETURN: Status and 64-bit sum
417 * DESCRIPTION: Add two 64-bit values, with checking for 64-bit overflow as
418 * well as 32-bit overflow if necessary (if the current global
427 /* Check for 64-bit overflow before the actual addition */ in acpi_ut_strtoul_add64()
429 if ((addend1 > 0) && (digit > (ACPI_UINT64_MAX - addend1))) { in acpi_ut_strtoul_add64()
435 /* Check for 32-bit overflow if necessary */ in acpi_ut_strtoul_add64()