mirror of
https://github.com/neovim/neovim.git
synced 2025-11-14 06:18:50 +00:00
Broken build on 32 bit: Fix -Wshorten-64-to-32.
Problem:
[ 48%] Building C object src/CMakeFiles/nvim.dir/os/mem.c.o
/Users/eliseo/projects/os/neovim/src/os/mem.c:9:32: error: implicit
conversion loses integer
precision: 'uint64_t' (aka 'unsigned long long') to 'long_u' (aka
'unsigned long')
[-Werror,-Wshorten-64-to-32]
return uv_get_total_memory() >> 10;
~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~^~~~~
Solution:
Avoid conversion. Make function return proper uint64_t.
Make users of the function accomodate the value if too big for them.
This commit is contained in:
committed by
Thiago de Arruda
parent
320fade350
commit
5f60bf4eb2
@@ -2011,8 +2011,11 @@ void set_init_1(void)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef HAVE_TOTAL_MEM
|
#ifdef HAVE_TOTAL_MEM
|
||||||
/* Use amount of memory available to Vim. */
|
/* Use half of amount of memory available to Vim. */
|
||||||
n = (os_get_total_mem_kib() >> 1);
|
/* If too much to fit in long_u, get long_u max */
|
||||||
|
uint64_t available_kib = os_get_total_mem_kib();
|
||||||
|
n = available_kib / 2 > ULONG_MAX ? ULONG_MAX
|
||||||
|
: (long_u)(available_kib /2);
|
||||||
#else
|
#else
|
||||||
n = (0x7fffffff >> 11);
|
n = (0x7fffffff >> 11);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "os/os.h"
|
#include "os/os.h"
|
||||||
|
|
||||||
long_u os_get_total_mem_kib(void) {
|
uint64_t os_get_total_mem_kib(void) {
|
||||||
// Convert bytes to KiB.
|
// Convert bytes to KiB.
|
||||||
return uv_get_total_memory() >> 10;
|
return uv_get_total_memory() >> 10;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ int os_rmdir(const char *path);
|
|||||||
int os_remove(const char *path);
|
int os_remove(const char *path);
|
||||||
|
|
||||||
/// Get the total system physical memory in KiB.
|
/// Get the total system physical memory in KiB.
|
||||||
long_u os_get_total_mem_kib(void);
|
uint64_t os_get_total_mem_kib(void);
|
||||||
const char *os_getenv(const char *name);
|
const char *os_getenv(const char *name);
|
||||||
int os_setenv(const char *name, const char *value, int overwrite);
|
int os_setenv(const char *name, const char *value, int overwrite);
|
||||||
char *os_getenvname_at_index(size_t index);
|
char *os_getenvname_at_index(size_t index);
|
||||||
|
|||||||
Reference in New Issue
Block a user