|
@@ -9,7 +9,6 @@
|
|
|
#include <dragonstub/linux/byteorder.h>
|
|
|
#include <dragonstub/linux/div64.h>
|
|
|
|
|
|
-
|
|
|
struct printf_spec {
|
|
|
unsigned int type : 8; /* format_type enum */
|
|
|
signed int field_width : 24; /* width of output field */
|
|
@@ -90,7 +89,7 @@ static noinline_for_stack int skip_atoi(const char **s)
|
|
|
|
|
|
static const u16 decpair[100] = {
|
|
|
#define _(x) (__force u16) cpu_to_le16(((x % 10) | ((x / 10) << 8)) + 0x3030)
|
|
|
- _( 0), _( 1), _( 2), _( 3), _( 4), _( 5), _( 6), _( 7), _( 8), _( 9),
|
|
|
+ _(0), _(1), _(2), _(3), _(4), _(5), _(6), _(7), _(8), _(9),
|
|
|
_(10), _(11), _(12), _(13), _(14), _(15), _(16), _(17), _(18), _(19),
|
|
|
_(20), _(21), _(22), _(23), _(24), _(25), _(26), _(27), _(28), _(29),
|
|
|
_(30), _(31), _(32), _(33), _(34), _(35), _(36), _(37), _(38), _(39),
|
|
@@ -188,14 +187,13 @@ static noinline_for_stack char *put_dec(char *buf, unsigned long long n)
|
|
|
|
|
|
#elif BITS_PER_LONG == 32 && BITS_PER_LONG_LONG == 64
|
|
|
|
|
|
-static void
|
|
|
-put_dec_full4(char *buf, unsigned r)
|
|
|
+static void put_dec_full4(char *buf, unsigned r)
|
|
|
{
|
|
|
unsigned q;
|
|
|
|
|
|
/* 0 <= r < 10^4 */
|
|
|
q = (r * 0x147b) >> 19;
|
|
|
- *((u16 *)buf) = decpair[r - 100*q];
|
|
|
+ *((u16 *)buf) = decpair[r - 100 * q];
|
|
|
buf += 2;
|
|
|
/* 0 <= q < 100 */
|
|
|
*((u16 *)buf) = decpair[q];
|
|
@@ -208,13 +206,12 @@ put_dec_full4(char *buf, unsigned r)
|
|
|
* helper will ever be asked to convert is 1,125,520,955.
|
|
|
* (second call in the put_dec code, assuming n is all-ones).
|
|
|
*/
|
|
|
-static noinline_for_stack
|
|
|
-unsigned put_dec_helper4(char *buf, unsigned x)
|
|
|
+static noinline_for_stack unsigned put_dec_helper4(char *buf, unsigned x)
|
|
|
{
|
|
|
- uint32_t q = (x * (uint64_t)0x346DC5D7) >> 43;
|
|
|
+ uint32_t q = (x * (uint64_t)0x346DC5D7) >> 43;
|
|
|
|
|
|
- put_dec_full4(buf, x - q * 10000);
|
|
|
- return q;
|
|
|
+ put_dec_full4(buf, x - q * 10000);
|
|
|
+ return q;
|
|
|
}
|
|
|
|
|
|
/* Based on code by Douglas W. Jones found at
|
|
@@ -222,36 +219,36 @@ unsigned put_dec_helper4(char *buf, unsigned x)
|
|
|
* (with permission from the author).
|
|
|
* Performs no 64-bit division and hence should be fast on 32-bit machines.
|
|
|
*/
|
|
|
-static
|
|
|
-char *put_dec(char *buf, unsigned long long n)
|
|
|
+static char *put_dec(char *buf, unsigned long long n)
|
|
|
{
|
|
|
uint32_t d3, d2, d1, q, h;
|
|
|
|
|
|
- if (n < 100*1000*1000)
|
|
|
+ if (n < 100 * 1000 * 1000)
|
|
|
return put_dec_trunc8(buf, n);
|
|
|
|
|
|
- d1 = ((uint32_t)n >> 16); /* implicit "& 0xffff" */
|
|
|
- h = (n >> 32);
|
|
|
- d2 = (h ) & 0xffff;
|
|
|
- d3 = (h >> 16); /* implicit "& 0xffff" */
|
|
|
+ d1 = ((uint32_t)n >> 16); /* implicit "& 0xffff" */
|
|
|
+ h = (n >> 32);
|
|
|
+ d2 = (h)&0xffff;
|
|
|
+ d3 = (h >> 16); /* implicit "& 0xffff" */
|
|
|
|
|
|
/* n = 2^48 d3 + 2^32 d2 + 2^16 d1 + d0
|
|
|
= 281_4749_7671_0656 d3 + 42_9496_7296 d2 + 6_5536 d1 + d0 */
|
|
|
- q = 656 * d3 + 7296 * d2 + 5536 * d1 + ((uint32_t)n & 0xffff);
|
|
|
+ q = 656 * d3 + 7296 * d2 + 5536 * d1 + ((uint32_t)n & 0xffff);
|
|
|
q = put_dec_helper4(buf, q);
|
|
|
|
|
|
q += 7671 * d3 + 9496 * d2 + 6 * d1;
|
|
|
- q = put_dec_helper4(buf+4, q);
|
|
|
+ q = put_dec_helper4(buf + 4, q);
|
|
|
|
|
|
q += 4749 * d3 + 42 * d2;
|
|
|
- q = put_dec_helper4(buf+8, q);
|
|
|
+ q = put_dec_helper4(buf + 8, q);
|
|
|
|
|
|
q += 281 * d3;
|
|
|
buf += 12;
|
|
|
if (q)
|
|
|
buf = put_dec_trunc8(buf, q);
|
|
|
- else while (buf[-1] == '0')
|
|
|
- --buf;
|
|
|
+ else
|
|
|
+ while (buf[-1] == '0')
|
|
|
+ --buf;
|
|
|
|
|
|
return buf;
|
|
|
}
|
|
@@ -548,12 +545,11 @@ static char *pointer_string(char *buf, char *end, const void *ptr,
|
|
|
return number(buf, end, (unsigned long int)ptr, spec);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-static noinline_for_stack
|
|
|
-char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
|
|
|
- const char *fmt)
|
|
|
+static noinline_for_stack char *hex_string(char *buf, char *end, u8 *addr,
|
|
|
+ struct printf_spec spec,
|
|
|
+ const char *fmt)
|
|
|
{
|
|
|
- int i, len = 1; /* if we pass '%ph[CDN]', field width remains
|
|
|
+ int i, len = 1; /* if we pass '%ph[CDN]', field width remains
|
|
|
negative value, fallback to the default */
|
|
|
char separator;
|
|
|
|
|
@@ -600,9 +596,10 @@ char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
|
|
|
return buf;
|
|
|
}
|
|
|
|
|
|
-static noinline_for_stack
|
|
|
-char *mac_address_string(char *buf, char *end, u8 *addr,
|
|
|
- struct printf_spec spec, const char *fmt)
|
|
|
+static noinline_for_stack char *mac_address_string(char *buf, char *end,
|
|
|
+ u8 *addr,
|
|
|
+ struct printf_spec spec,
|
|
|
+ const char *fmt)
|
|
|
{
|
|
|
char mac_addr[sizeof("xx:xx:xx:xx:xx:xx")];
|
|
|
char *p = mac_addr;
|
|
@@ -647,9 +644,7 @@ static char *default_pointer(char *buf, char *end, const void *ptr,
|
|
|
return pointer_string(buf, end, ptr, spec);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-static char *err_ptr(char *buf, char *end, void *ptr,
|
|
|
- struct printf_spec spec)
|
|
|
+static char *err_ptr(char *buf, char *end, void *ptr, struct printf_spec spec)
|
|
|
{
|
|
|
int err = PTR_ERR(ptr);
|
|
|
// const char *sym = errname(err);
|
|
@@ -825,38 +820,38 @@ static noinline_for_stack char *pointer(const char *fmt, char *buf, char *end,
|
|
|
/* [mM]F (FDDI) */
|
|
|
/* [mM]R (Reverse order; Bluetooth) */
|
|
|
return mac_address_string(buf, end, ptr, spec, fmt);
|
|
|
- // case 'I': /* Formatted IP supported
|
|
|
- // * 4: 1.2.3.4
|
|
|
- // * 6: 0001:0203:...:0708
|
|
|
- // * 6c: 1::708 or 1::1.2.3.4
|
|
|
- // */
|
|
|
- // case 'i': /* Contiguous:
|
|
|
- // * 4: 001.002.003.004
|
|
|
- // * 6: 000102...0f
|
|
|
- // */
|
|
|
- // return ip_addr_string(buf, end, ptr, spec, fmt);
|
|
|
- // case 'E':
|
|
|
- // return escaped_string(buf, end, ptr, spec, fmt);
|
|
|
- // case 'U':
|
|
|
- // return uuid_string(buf, end, ptr, spec, fmt);
|
|
|
- // case 'V':
|
|
|
- // return va_format(buf, end, ptr, spec, fmt);
|
|
|
- // case 'K':
|
|
|
- // return restricted_pointer(buf, end, ptr, spec);
|
|
|
- // case 'N':
|
|
|
- // return netdev_bits(buf, end, ptr, spec, fmt);
|
|
|
- // case '4':
|
|
|
- // return fourcc_string(buf, end, ptr, spec, fmt);
|
|
|
- // case 'a':
|
|
|
- // return address_val(buf, end, ptr, spec, fmt);
|
|
|
- // case 'd':
|
|
|
- // return dentry_name(buf, end, ptr, spec, fmt);
|
|
|
- // case 't':
|
|
|
- // return time_and_date(buf, end, ptr, spec, fmt);
|
|
|
- // case 'C':
|
|
|
- // return clock(buf, end, ptr, spec, fmt);
|
|
|
- // case 'D':
|
|
|
- // return file_dentry_name(buf, end, ptr, spec, fmt);
|
|
|
+ // case 'I': /* Formatted IP supported
|
|
|
+ // * 4: 1.2.3.4
|
|
|
+ // * 6: 0001:0203:...:0708
|
|
|
+ // * 6c: 1::708 or 1::1.2.3.4
|
|
|
+ // */
|
|
|
+ // case 'i': /* Contiguous:
|
|
|
+ // * 4: 001.002.003.004
|
|
|
+ // * 6: 000102...0f
|
|
|
+ // */
|
|
|
+ // return ip_addr_string(buf, end, ptr, spec, fmt);
|
|
|
+ // case 'E':
|
|
|
+ // return escaped_string(buf, end, ptr, spec, fmt);
|
|
|
+ // case 'U':
|
|
|
+ // return uuid_string(buf, end, ptr, spec, fmt);
|
|
|
+ // case 'V':
|
|
|
+ // return va_format(buf, end, ptr, spec, fmt);
|
|
|
+ // case 'K':
|
|
|
+ // return restricted_pointer(buf, end, ptr, spec);
|
|
|
+ // case 'N':
|
|
|
+ // return netdev_bits(buf, end, ptr, spec, fmt);
|
|
|
+ // case '4':
|
|
|
+ // return fourcc_string(buf, end, ptr, spec, fmt);
|
|
|
+ // case 'a':
|
|
|
+ // return address_val(buf, end, ptr, spec, fmt);
|
|
|
+ // case 'd':
|
|
|
+ // return dentry_name(buf, end, ptr, spec, fmt);
|
|
|
+ // case 't':
|
|
|
+ // return time_and_date(buf, end, ptr, spec, fmt);
|
|
|
+ // case 'C':
|
|
|
+ // return clock(buf, end, ptr, spec, fmt);
|
|
|
+ // case 'D':
|
|
|
+ // return file_dentry_name(buf, end, ptr, spec, fmt);
|
|
|
#ifdef CONFIG_BLOCK
|
|
|
case 'g':
|
|
|
return bdev_name(buf, end, ptr, spec, fmt);
|