diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2023-12-13 17:48:11 +0100 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2023-12-13 21:12:47 +0100 |
commit | 5445ff4a51fcee4d281f79b5f54b349290d0327d (patch) | |
tree | 25933440fe183c754d10fc36a056de67ad77296c /libgomp | |
parent | 063564ecbfc618cd019f86216a0224e144effae1 (diff) | |
download | gcc-5445ff4a51fcee4d281f79b5f54b349290d0327d.zip gcc-5445ff4a51fcee4d281f79b5f54b349290d0327d.tar.gz gcc-5445ff4a51fcee4d281f79b5f54b349290d0327d.tar.bz2 |
Fix 'libgomp/config/linux/allocator.c' 'size_t' vs. '%ld' format string mismatch
Fix-up for commit 348874f0baac0f22c98ab11abbfa65fd172f6bdd
"libgomp: basic pinned memory on Linux", which may result in build failures
as follow, for example, for the '-m32' multilib of x86_64-pc-linux-gnu:
In file included from [...]/source-gcc/libgomp/config/linux/allocator.c:31:
[...]/source-gcc/libgomp/config/linux/allocator.c: In function ‘linux_memspace_alloc’:
[...]/source-gcc/libgomp/config/linux/allocator.c:70:26: error: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=]
70 | gomp_debug (0, "libgomp: failed to pin %ld bytes of"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71 | " memory (ulimit too low?)\n", size);
| ~~~~
| |
| size_t {aka unsigned int}
[...]/source-gcc/libgomp/libgomp.h:186:29: note: in definition of macro ‘gomp_debug’
186 | (gomp_debug) ((KIND), __VA_ARGS__); \
| ^~~~~~~~~~~
[...]/source-gcc/libgomp/config/linux/allocator.c:70:52: note: format string is defined here
70 | gomp_debug (0, "libgomp: failed to pin %ld bytes of"
| ~~^
| |
| long int
| %d
cc1: all warnings being treated as errors
make[9]: *** [allocator.lo] Error 1
make[9]: Leaving directory `[...]/build-gcc/x86_64-pc-linux-gnu/32/libgomp'
[...]
Fix this in the same way as used elsewhere in libgomp.
libgomp/
* config/linux/allocator.c (linux_memspace_alloc): Fix 'size_t'
vs. '%ld' format string mismatch.
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/config/linux/allocator.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libgomp/config/linux/allocator.c b/libgomp/config/linux/allocator.c index 269d0d6..6ffa241 100644 --- a/libgomp/config/linux/allocator.c +++ b/libgomp/config/linux/allocator.c @@ -50,6 +50,9 @@ #include <sys/mman.h> #include <string.h> #include "libgomp.h" +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> /* For PRIu64. */ +#endif static void * linux_memspace_alloc (omp_memspace_handle_t memspace, size_t size, int pin) @@ -67,8 +70,13 @@ linux_memspace_alloc (omp_memspace_handle_t memspace, size_t size, int pin) if (mlock (addr, size)) { - gomp_debug (0, "libgomp: failed to pin %ld bytes of" - " memory (ulimit too low?)\n", size); +#ifdef HAVE_INTTYPES_H + gomp_debug (0, "libgomp: failed to pin %"PRIu64" bytes of" + " memory (ulimit too low?)\n", (uint64_t) size); +#else + gomp_debug (0, "libgomp: failed to pin %lu bytes of" + " memory (ulimit too low?)\n", (unsigned long) size); +#endif munmap (addr, size); return NULL; } |