aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/fileio.c b/src/fileio.c
index c129f19872e..81c29ca0cca 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6081,16 +6081,18 @@ effect except for flushing STREAM's data. */)
6081 6081
6082#ifndef DOS_NT 6082#ifndef DOS_NT
6083 6083
6084/* Yield a Lisp float as close as possible to BLOCKSIZE * BLOCKS, with 6084/* Yield a Lisp number equal to BLOCKSIZE * BLOCKS, with the result
6085 the result negated if NEGATE. */ 6085 negated if NEGATE. */
6086static Lisp_Object 6086static Lisp_Object
6087blocks_to_bytes (uintmax_t blocksize, uintmax_t blocks, bool negate) 6087blocks_to_bytes (uintmax_t blocksize, uintmax_t blocks, bool negate)
6088{ 6088{
6089 /* On typical platforms the following code is accurate to 53 bits, 6089 intmax_t n;
6090 which is close enough. BLOCKSIZE is invariably a power of 2, so 6090 if (!INT_MULTIPLY_WRAPV (blocksize, blocks, &n))
6091 converting it to double does not lose information. */ 6091 return make_int (negate ? -n : n);
6092 double bs = blocksize; 6092 Lisp_Object bs = make_uint (blocksize);
6093 return make_float (negate ? -bs * -blocks : bs * blocks); 6093 if (negate)
6094 bs = CALLN (Fminus, bs);
6095 return CALLN (Ftimes, bs, make_uint (blocks));
6094} 6096}
6095 6097
6096DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0, 6098DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0,