2 * (C) Copyright 2000-2009
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
30 * strict_strtoul - convert a string to an unsigned long strictly
31 * @param cp The string to be converted
32 * @param base The number base to use
33 * @param res The converted result value
34 * @return 0 if conversion is successful and *res is set to the converted
35 * value, otherwise it returns -EINVAL and *res is set to 0.
37 * strict_strtoul converts a string to an unsigned long only if the
38 * string is really an unsigned long string, any string containing
39 * any invalid char at the tail will be rejected and -EINVAL is returned,
40 * only a newline char at the tail is acceptible because people generally
41 * change a module parameter in the following way:
43 * echo 1024 > /sys/module/e1000/parameters/copybreak
45 * echo will append a newline to the tail.
47 * simple_strtoul just ignores the successive invalid characters and
48 * return the converted value of prefix part of the string.
50 * Copied this function from Linux 2.6.38 commit ID:
51 * 521cb40b0c44418a4fd36dc633f575813d59a43d
54 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
55 unsigned long long simple_strtoull(const char *cp, char **endp,
57 long simple_strtol(const char *cp, char **endp, unsigned int base);
58 void panic(const char *fmt, ...)
59 __attribute__ ((format (__printf__, 1, 2), noreturn));
62 * Format a string and place it in a buffer
64 * @param buf The buffer to place the result into
65 * @param fmt The format string to use
66 * @param ... Arguments for the format string
68 * The function returns the number of characters written
71 * See the vsprintf() documentation for format string extensions over C99.
73 int sprintf(char *buf, const char *fmt, ...)
74 __attribute__ ((format (__printf__, 2, 3)));
77 * Format a string and place it in a buffer (va_list version)
79 * @param buf The buffer to place the result into
80 * @param size The size of the buffer, including the trailing null space
81 * @param fmt The format string to use
82 * @param args Arguments for the format string
83 * @return the number of characters which have been written into
84 * the @buf not including the trailing '\0'. If @size is == 0 the function
87 * If you're not already dealing with a va_list consider using scnprintf().
89 * See the vsprintf() documentation for format string extensions over C99.
91 int vsprintf(char *buf, const char *fmt, va_list args);
92 char *simple_itoa(ulong i);
94 #ifdef CONFIG_SYS_VSNPRINTF
96 * Format a string and place it in a buffer
98 * @param buf The buffer to place the result into
99 * @param size The size of the buffer, including the trailing null space
100 * @param fmt The format string to use
101 * @param ... Arguments for the format string
102 * @return the number of characters which would be
103 * generated for the given input, excluding the trailing null,
104 * as per ISO C99. If the return is greater than or equal to
105 * @size, the resulting string is truncated.
107 * See the vsprintf() documentation for format string extensions over C99.
109 int snprintf(char *buf, size_t size, const char *fmt, ...)
110 __attribute__ ((format (__printf__, 3, 4)));
113 * Format a string and place it in a buffer
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 ... Arguments for the format string
120 * The return value is the number of characters written into @buf not including
121 * the trailing '\0'. If @size is == 0 the function returns 0.
123 * See the vsprintf() documentation for format string extensions over C99.
125 int scnprintf(char *buf, size_t size, const char *fmt, ...)
126 __attribute__ ((format (__printf__, 3, 4)));
129 * Format a string and place it in a buffer (base function)
131 * @param buf The buffer to place the result into
132 * @param size The size of the buffer, including the trailing null space
133 * @param fmt The format string to use
134 * @param args Arguments for the format string
135 * @return The number characters which would be generated for the given
136 * input, excluding the trailing '\0', as per ISO C99. Note that fewer
137 * characters may be written if this number of characters is >= size.
139 * This function follows C99 vsnprintf, but has some extensions:
140 * %pS output the name of a text symbol
141 * %pF output the name of a function pointer
142 * %pR output the address range in a struct resource
144 * The function returns the number of characters which would be
145 * generated for the given input, excluding the trailing '\0',
148 * Call this function if you are already dealing with a va_list.
149 * You probably want snprintf() instead.
151 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
154 * Format a string and place it in a buffer (va_list version)
156 * @param buf The buffer to place the result into
157 * @param size The size of the buffer, including the trailing null space
158 * @param fmt The format string to use
159 * @param args Arguments for the format string
160 * @return the number of characters which have been written into
161 * the @buf not including the trailing '\0'. If @size is == 0 the function
164 * If you're not already dealing with a va_list consider using scnprintf().
166 * See the vsprintf() documentation for format string extensions over C99.
168 int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
171 * Use macros to silently drop the size parameter. Note that the 'cn'
172 * versions are the same as the 'n' versions since the functions assume
173 * there is always enough buffer space when !CONFIG_SYS_VSNPRINTF
175 #define snprintf(buf, size, fmt, args...) sprintf(buf, fmt, ##args)
176 #define scnprintf(buf, size, fmt, args...) sprintf(buf, fmt, ##args)
177 #define vsnprintf(buf, size, fmt, args...) vsprintf(buf, fmt, ##args)
178 #define vscnprintf(buf, size, fmt, args...) vsprintf(buf, fmt, ##args)
179 #endif /* CONFIG_SYS_VSNPRINTF */
182 * print_grouped_ull() - print a value with digits grouped by ','
184 * This prints a value with grouped digits, like 12,345,678 to make it easier
187 * @val: Value to print
188 * @digits: Number of digiits to print
190 void print_grouped_ull(unsigned long long int_val, int digits);