2 * (C) Copyright 2000-2009
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
11 ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
14 * strict_strtoul - convert a string to an unsigned long strictly
15 * @param cp The string to be converted
16 * @param base The number base to use
17 * @param res The converted result value
18 * @return 0 if conversion is successful and *res is set to the converted
19 * value, otherwise it returns -EINVAL and *res is set to 0.
21 * strict_strtoul converts a string to an unsigned long only if the
22 * string is really an unsigned long string, any string containing
23 * any invalid char at the tail will be rejected and -EINVAL is returned,
24 * only a newline char at the tail is acceptible because people generally
25 * change a module parameter in the following way:
27 * echo 1024 > /sys/module/e1000/parameters/copybreak
29 * echo will append a newline to the tail.
31 * simple_strtoul just ignores the successive invalid characters and
32 * return the converted value of prefix part of the string.
34 * Copied this function from Linux 2.6.38 commit ID:
35 * 521cb40b0c44418a4fd36dc633f575813d59a43d
38 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
39 unsigned long long simple_strtoull(const char *cp, char **endp,
41 long simple_strtol(const char *cp, char **endp, unsigned int base);
42 void panic(const char *fmt, ...)
43 __attribute__ ((format (__printf__, 1, 2), noreturn));
46 * Format a string and place it in a buffer
48 * @param buf The buffer to place the result into
49 * @param fmt The format string to use
50 * @param ... Arguments for the format string
52 * The function returns the number of characters written
55 * See the vsprintf() documentation for format string extensions over C99.
57 int sprintf(char *buf, const char *fmt, ...)
58 __attribute__ ((format (__printf__, 2, 3)));
61 * Format a string and place it in a buffer (va_list version)
63 * @param buf The buffer to place the result into
64 * @param size The size of the buffer, including the trailing null space
65 * @param fmt The format string to use
66 * @param args Arguments for the format string
67 * @return the number of characters which have been written into
68 * the @buf not including the trailing '\0'. If @size is == 0 the function
71 * If you're not already dealing with a va_list consider using scnprintf().
73 * See the vsprintf() documentation for format string extensions over C99.
75 int vsprintf(char *buf, const char *fmt, va_list args);
76 char *simple_itoa(ulong i);
78 #ifdef CONFIG_SYS_VSNPRINTF
80 * Format a string and place it in a buffer
82 * @param buf The buffer to place the result into
83 * @param size The size of the buffer, including the trailing null space
84 * @param fmt The format string to use
85 * @param ... Arguments for the format string
86 * @return the number of characters which would be
87 * generated for the given input, excluding the trailing null,
88 * as per ISO C99. If the return is greater than or equal to
89 * @size, the resulting string is truncated.
91 * See the vsprintf() documentation for format string extensions over C99.
93 int snprintf(char *buf, size_t size, const char *fmt, ...)
94 __attribute__ ((format (__printf__, 3, 4)));
97 * Format a string and place it in a buffer
99 * @param buf The buffer to place the result into
100 * @param size The size of the buffer, including the trailing null space
101 * @param fmt The format string to use
102 * @param ... Arguments for the format string
104 * The return value is the number of characters written into @buf not including
105 * the trailing '\0'. If @size is == 0 the function returns 0.
107 * See the vsprintf() documentation for format string extensions over C99.
109 int scnprintf(char *buf, size_t size, const char *fmt, ...)
110 __attribute__ ((format (__printf__, 3, 4)));
113 * Format a string and place it in a buffer (base function)
115 * @param buf The buffer to place the result into
116 * @param size The size of the buffer, including the trailing null space
117 * @param fmt The format string to use
118 * @param args Arguments for the format string
119 * @return The number characters which would be generated for the given
120 * input, excluding the trailing '\0', as per ISO C99. Note that fewer
121 * characters may be written if this number of characters is >= size.
123 * This function follows C99 vsnprintf, but has some extensions:
124 * %pS output the name of a text symbol
125 * %pF output the name of a function pointer
126 * %pR output the address range in a struct resource
128 * The function returns the number of characters which would be
129 * generated for the given input, excluding the trailing '\0',
132 * Call this function if you are already dealing with a va_list.
133 * You probably want snprintf() instead.
135 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
138 * Format a string and place it in a buffer (va_list version)
140 * @param buf The buffer to place the result into
141 * @param size The size of the buffer, including the trailing null space
142 * @param fmt The format string to use
143 * @param args Arguments for the format string
144 * @return the number of characters which have been written into
145 * the @buf not including the trailing '\0'. If @size is == 0 the function
148 * If you're not already dealing with a va_list consider using scnprintf().
150 * See the vsprintf() documentation for format string extensions over C99.
152 int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
155 * Use macros to silently drop the size parameter. Note that the 'cn'
156 * versions are the same as the 'n' versions since the functions assume
157 * there is always enough buffer space when !CONFIG_SYS_VSNPRINTF
159 #define snprintf(buf, size, fmt, args...) sprintf(buf, fmt, ##args)
160 #define scnprintf(buf, size, fmt, args...) sprintf(buf, fmt, ##args)
161 #define vsnprintf(buf, size, fmt, args...) vsprintf(buf, fmt, ##args)
162 #define vscnprintf(buf, size, fmt, args...) vsprintf(buf, fmt, ##args)
163 #endif /* CONFIG_SYS_VSNPRINTF */
166 * print_grouped_ull() - print a value with digits grouped by ','
168 * This prints a value with grouped digits, like 12,345,678 to make it easier
171 * @val: Value to print
172 * @digits: Number of digiits to print
174 void print_grouped_ull(unsigned long long int_val, int digits);