diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2017-02-01 22:29:58 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-07-18 09:51:30 +0100 |
commit | 18afed0f98d020608c65293ecb9246dab6c58db3 (patch) | |
tree | 376aa1289f3f0e934e8381507c337d68e1e4b89a | |
parent | d416bdac2fff5eed7cfa70499ff61c8b8a9ca7ce (diff) | |
download | busybox-w32-18afed0f98d020608c65293ecb9246dab6c58db3.tar.gz busybox-w32-18afed0f98d020608c65293ecb9246dab6c58db3.tar.bz2 busybox-w32-18afed0f98d020608c65293ecb9246dab6c58db3.zip |
Use %I64* formats with MinGW instead of %ll* formats
The MSVC runtime uses the format specified %I64 for 64-bit data types;
It does not understand e.g. %llu for unsigned long longs.
However, mingw-w64 provides a compatibility mode in its runtime wrapper
which can be activated by defining the constant __USE_MINGW_ANSI_STDIO=1
in which case we must refrain from overriding the %ll* formats.
This fixes quite a couple of compile warnings when building with the
mingw-w64 compiler.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
-rw-r--r-- | coreutils/expr.c | 2 | ||||
-rw-r--r-- | coreutils/factor.c | 4 | ||||
-rw-r--r-- | coreutils/ls.c | 2 | ||||
-rw-r--r-- | coreutils/sum.c | 4 | ||||
-rw-r--r-- | editors/awk.c | 2 | ||||
-rw-r--r-- | include/libbb.h | 9 | ||||
-rw-r--r-- | libbb/xatonum_template.c | 5 | ||||
-rw-r--r-- | miscutils/dc.c | 2 | ||||
-rw-r--r-- | procps/iostat.c | 2 | ||||
-rw-r--r-- | procps/mpstat.c | 2 | ||||
-rw-r--r-- | shell/math.h | 2 |
11 files changed, 22 insertions, 14 deletions
diff --git a/coreutils/expr.c b/coreutils/expr.c index 5d2fbf2f7..639d29a55 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c | |||
@@ -84,7 +84,7 @@ | |||
84 | #if ENABLE_EXPR_MATH_SUPPORT_64 | 84 | #if ENABLE_EXPR_MATH_SUPPORT_64 |
85 | typedef int64_t arith_t; | 85 | typedef int64_t arith_t; |
86 | 86 | ||
87 | #define PF_REZ "ll" | 87 | #define PF_REZ LL_FMT |
88 | #define PF_REZ_TYPE (long long) | 88 | #define PF_REZ_TYPE (long long) |
89 | #define STRTOL(s, e, b) strtoll(s, e, b) | 89 | #define STRTOL(s, e, b) strtoll(s, e, b) |
90 | #else | 90 | #else |
diff --git a/coreutils/factor.c b/coreutils/factor.c index 205cdc053..8782d3d1e 100644 --- a/coreutils/factor.c +++ b/coreutils/factor.c | |||
@@ -161,7 +161,7 @@ static NOINLINE void factorize(wide_t N) | |||
161 | } | 161 | } |
162 | end: | 162 | end: |
163 | if (N > 1) | 163 | if (N > 1) |
164 | printf(" %llu", N); | 164 | printf(" %"LL_FMT"u", N); |
165 | bb_putchar('\n'); | 165 | bb_putchar('\n'); |
166 | } | 166 | } |
167 | 167 | ||
@@ -175,7 +175,7 @@ static void factorize_numstr(const char *numstr) | |||
175 | N = bb_strtoull(numstr, NULL, 10); | 175 | N = bb_strtoull(numstr, NULL, 10); |
176 | if (errno) | 176 | if (errno) |
177 | bb_show_usage(); | 177 | bb_show_usage(); |
178 | printf("%llu:", N); | 178 | printf("%"LL_FMT"u:", N); |
179 | factorize(N); | 179 | factorize(N); |
180 | } | 180 | } |
181 | 181 | ||
diff --git a/coreutils/ls.c b/coreutils/ls.c index 6780057da..61b4409a7 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -496,7 +496,7 @@ static NOINLINE unsigned display_single(const struct dnode *dn) | |||
496 | lpath = xmalloc_readlink_or_warn(dn->fullname); | 496 | lpath = xmalloc_readlink_or_warn(dn->fullname); |
497 | 497 | ||
498 | if (opt & OPT_i) /* show inode# */ | 498 | if (opt & OPT_i) /* show inode# */ |
499 | column += printf("%7llu ", (long long) dn->dn_ino); | 499 | column += printf("%7"LL_FMT"u ", (long long) dn->dn_ino); |
500 | //TODO: -h should affect -s too: | 500 | //TODO: -h should affect -s too: |
501 | if (opt & OPT_s) /* show allocated blocks */ | 501 | if (opt & OPT_s) /* show allocated blocks */ |
502 | column += printf("%6"OFF_FMT"u ", (off_t) (dn->dn_blocks >> 1)); | 502 | column += printf("%6"OFF_FMT"u ", (off_t) (dn->dn_blocks >> 1)); |
diff --git a/coreutils/sum.c b/coreutils/sum.c index c55293dc9..2a91f963c 100644 --- a/coreutils/sum.c +++ b/coreutils/sum.c | |||
@@ -82,9 +82,9 @@ static unsigned sum_file(const char *file, unsigned type) | |||
82 | if (type >= SUM_SYSV) { | 82 | if (type >= SUM_SYSV) { |
83 | r = (s & 0xffff) + ((s & 0xffffffff) >> 16); | 83 | r = (s & 0xffff) + ((s & 0xffffffff) >> 16); |
84 | s = (r & 0xffff) + (r >> 16); | 84 | s = (r & 0xffff) + (r >> 16); |
85 | printf("%u %llu %s\n", s, (total_bytes + 511) / 512, file); | 85 | printf("%u %"LL_FMT"u %s\n", s, (total_bytes + 511) / 512, file); |
86 | } else | 86 | } else |
87 | printf("%05u %5llu %s\n", s, (total_bytes + 1023) / 1024, file); | 87 | printf("%05u %5"OFF_FMT"u %s\n", s, (total_bytes + 1023) / 1024, file); |
88 | return 1; | 88 | return 1; |
89 | #undef buf | 89 | #undef buf |
90 | } | 90 | } |
diff --git a/editors/awk.c b/editors/awk.c index 84ba125cd..e8e2c96f8 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -2078,7 +2078,7 @@ static int fmt_num(char *b, int size, const char *format, double n, int int_as_i | |||
2078 | const char *s = format; | 2078 | const char *s = format; |
2079 | 2079 | ||
2080 | if (int_as_int && n == (long long)n) { | 2080 | if (int_as_int && n == (long long)n) { |
2081 | r = snprintf(b, size, "%lld", (long long)n); | 2081 | r = snprintf(b, size, "%"LL_FMT"d", (long long)n); |
2082 | } else { | 2082 | } else { |
2083 | do { c = *s; } while (c && *++s); | 2083 | do { c = *s; } while (c && *++s); |
2084 | if (strchr("diouxX", c)) { | 2084 | if (strchr("diouxX", c)) { |
diff --git a/include/libbb.h b/include/libbb.h index 9313a557a..0bc8cf29e 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -252,6 +252,13 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | |||
252 | : ((T)1 << (sizeof(T)*8-1)) \ | 252 | : ((T)1 << (sizeof(T)*8-1)) \ |
253 | ) | 253 | ) |
254 | 254 | ||
255 | #if ENABLE_PLATFORM_MINGW32 && \ | ||
256 | (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO) | ||
257 | #define LL_FMT "I64" | ||
258 | #else | ||
259 | #define LL_FMT "ll" | ||
260 | #endif | ||
261 | |||
255 | /* Large file support */ | 262 | /* Large file support */ |
256 | /* Note that CONFIG_LFS=y forces bbox to be built with all common ops | 263 | /* Note that CONFIG_LFS=y forces bbox to be built with all common ops |
257 | * (stat, lseek etc) mapped to "largefile" variants by libc. | 264 | * (stat, lseek etc) mapped to "largefile" variants by libc. |
@@ -277,7 +284,7 @@ typedef unsigned long long uoff_t; | |||
277 | # define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX) | 284 | # define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX) |
278 | # define BB_STRTOOFF bb_strtoull | 285 | # define BB_STRTOOFF bb_strtoull |
279 | # define STRTOOFF strtoull | 286 | # define STRTOOFF strtoull |
280 | # define OFF_FMT "ll" | 287 | # define OFF_FMT LL_FMT |
281 | # endif | 288 | # endif |
282 | #else | 289 | #else |
283 | /* CONFIG_LFS is off */ | 290 | /* CONFIG_LFS is off */ |
diff --git a/libbb/xatonum_template.c b/libbb/xatonum_template.c index e0471983c..0d5d35b47 100644 --- a/libbb/xatonum_template.c +++ b/libbb/xatonum_template.c | |||
@@ -67,7 +67,7 @@ unsigned type FAST_FUNC xstrtou(_range_sfx)(const char *numstr, int base, | |||
67 | if (r >= lower && r <= upper) | 67 | if (r >= lower && r <= upper) |
68 | return r; | 68 | return r; |
69 | range: | 69 | range: |
70 | bb_error_msg_and_die("number %s is not in %llu..%llu range", | 70 | bb_error_msg_and_die("number %s is not in %"LL_FMT"u..%"LL_FMT"u range", |
71 | numstr, (unsigned long long)lower, | 71 | numstr, (unsigned long long)lower, |
72 | (unsigned long long)upper); | 72 | (unsigned long long)upper); |
73 | inval: | 73 | inval: |
@@ -144,7 +144,8 @@ type FAST_FUNC xstrto(_range_sfx)(const char *numstr, int base, | |||
144 | } | 144 | } |
145 | 145 | ||
146 | if (r < lower || r > upper) { | 146 | if (r < lower || r > upper) { |
147 | bb_error_msg_and_die("number %s is not in %lld..%lld range", | 147 | bb_error_msg_and_die("number %s is not in " |
148 | "%"LL_FMT"d..%"LL_FMT"d range", | ||
148 | numstr, (long long)lower, (long long)upper); | 149 | numstr, (long long)lower, (long long)upper); |
149 | } | 150 | } |
150 | 151 | ||
diff --git a/miscutils/dc.c b/miscutils/dc.c index 7986fef5f..6b8364dd9 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c | |||
@@ -56,7 +56,7 @@ typedef unsigned long data_t; | |||
56 | #define DATA_FMT "l" | 56 | #define DATA_FMT "l" |
57 | #else | 57 | #else |
58 | typedef unsigned long long data_t; | 58 | typedef unsigned long long data_t; |
59 | #define DATA_FMT "ll" | 59 | #define DATA_FMT LL_FMT |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | 62 | ||
diff --git a/procps/iostat.c b/procps/iostat.c index c290c594b..2db343f69 100644 --- a/procps/iostat.c +++ b/procps/iostat.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #if 1 | 29 | #if 1 |
30 | typedef unsigned long long cputime_t; | 30 | typedef unsigned long long cputime_t; |
31 | typedef long long icputime_t; | 31 | typedef long long icputime_t; |
32 | # define FMT_DATA "ll" | 32 | # define FMT_DATA LL_FMT |
33 | # define CPUTIME_MAX (~0ULL) | 33 | # define CPUTIME_MAX (~0ULL) |
34 | #else | 34 | #else |
35 | typedef unsigned long cputime_t; | 35 | typedef unsigned long cputime_t; |
diff --git a/procps/mpstat.c b/procps/mpstat.c index 6028903fa..8a79fd8ba 100644 --- a/procps/mpstat.c +++ b/procps/mpstat.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #if 1 | 49 | #if 1 |
50 | typedef unsigned long long data_t; | 50 | typedef unsigned long long data_t; |
51 | typedef long long idata_t; | 51 | typedef long long idata_t; |
52 | #define FMT_DATA "ll" | 52 | #define FMT_DATA LL_FMT |
53 | #define DATA_MAX ULLONG_MAX | 53 | #define DATA_MAX ULLONG_MAX |
54 | #else | 54 | #else |
55 | typedef unsigned long data_t; | 55 | typedef unsigned long data_t; |
diff --git a/shell/math.h b/shell/math.h index 32e1ffe35..90eb49144 100644 --- a/shell/math.h +++ b/shell/math.h | |||
@@ -65,7 +65,7 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | |||
65 | 65 | ||
66 | #if ENABLE_FEATURE_SH_MATH_64 | 66 | #if ENABLE_FEATURE_SH_MATH_64 |
67 | typedef long long arith_t; | 67 | typedef long long arith_t; |
68 | #define ARITH_FMT "%lld" | 68 | #define ARITH_FMT "%"LL_FMT"d" |
69 | #define strto_arith_t strtoull | 69 | #define strto_arith_t strtoull |
70 | #else | 70 | #else |
71 | typedef long arith_t; | 71 | typedef long arith_t; |