mirror of https://git.tukaani.org/xz.git
Consistently round up the memory usage limit in messages.
It still feels a bit wrong to round 1 byte to 1 MiB but at least it is now done consistently so that the same byte value is always rounded the same way to MiB.
This commit is contained in:
parent
9886d436ff
commit
00fc1211ae
|
@ -1016,7 +1016,8 @@ message_memlimit(void)
|
||||||
printf("%" PRIu64 "\n", hardware_memlimit_get());
|
printf("%" PRIu64 "\n", hardware_memlimit_get());
|
||||||
else
|
else
|
||||||
printf(_("%s MiB (%s bytes)\n"),
|
printf(_("%s MiB (%s bytes)\n"),
|
||||||
uint64_to_str(hardware_memlimit_get() >> 20, 0),
|
uint64_to_str(
|
||||||
|
round_up_to_mib(hardware_memlimit_get()), 0),
|
||||||
uint64_to_str(hardware_memlimit_get(), 1));
|
uint64_to_str(hardware_memlimit_get(), 1));
|
||||||
|
|
||||||
tuklib_exit(E_SUCCESS, E_ERROR, verbosity != V_SILENT);
|
tuklib_exit(E_SUCCESS, E_ERROR, verbosity != V_SILENT);
|
||||||
|
@ -1180,7 +1181,7 @@ message_help(bool long_help)
|
||||||
if (long_help) {
|
if (long_help) {
|
||||||
printf(_(
|
printf(_(
|
||||||
"On this system and configuration, this program will use a maximum of roughly\n"
|
"On this system and configuration, this program will use a maximum of roughly\n"
|
||||||
"%s MiB RAM and "), uint64_to_str(hardware_memlimit_get() / (1024 * 1024), 0));
|
"%s MiB RAM and "), uint64_to_str(round_up_to_mib(hardware_memlimit_get()), 0));
|
||||||
printf(N_("one thread.\n\n", "%s threads.\n\n",
|
printf(N_("one thread.\n\n", "%s threads.\n\n",
|
||||||
hardware_threadlimit_get()),
|
hardware_threadlimit_get()),
|
||||||
uint64_to_str(hardware_threadlimit_get(), 0));
|
uint64_to_str(hardware_threadlimit_get(), 0));
|
||||||
|
|
|
@ -66,6 +66,10 @@ my_errorf(const char *fmt, ...)
|
||||||
static void lzma_attribute((noreturn))
|
static void lzma_attribute((noreturn))
|
||||||
help(void)
|
help(void)
|
||||||
{
|
{
|
||||||
|
// Round up to the next MiB and do it correctly also with UINT64_MAX.
|
||||||
|
const uint64_t mem_mib = (memlimit >> 20)
|
||||||
|
+ ((memlimit & ((UINT32_C(1) << 20) - 1)) != 0);
|
||||||
|
|
||||||
printf(
|
printf(
|
||||||
"Usage: %s [OPTION]... [FILE]...\n"
|
"Usage: %s [OPTION]... [FILE]...\n"
|
||||||
"Uncompress files in the ." TOOL_FORMAT " format to the standard output.\n"
|
"Uncompress files in the ." TOOL_FORMAT " format to the standard output.\n"
|
||||||
|
@ -85,8 +89,7 @@ help(void)
|
||||||
"%" PRIu64 " MiB RAM.\n"
|
"%" PRIu64 " MiB RAM.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Report bugs to <" PACKAGE_BUGREPORT "> (in English or Finnish).\n"
|
"Report bugs to <" PACKAGE_BUGREPORT "> (in English or Finnish).\n"
|
||||||
PACKAGE_NAME " home page: <" PACKAGE_URL ">\n",
|
PACKAGE_NAME " home page: <" PACKAGE_URL ">\n", progname, mem_mib);
|
||||||
progname, memlimit / (1024 * 1024));
|
|
||||||
tuklib_exit(EXIT_SUCCESS, EXIT_FAILURE, display_errors);
|
tuklib_exit(EXIT_SUCCESS, EXIT_FAILURE, display_errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue