From fb59dd8612720df56e38157e2525952096a3ae14 Mon Sep 17 00:00:00 2001 From: Tom Cornebize Date: Tue, 11 Apr 2017 16:40:41 +0200 Subject: [PATCH 1/1] Remove warnings. --- src/smpi/smpi_global.cpp | 16 ++++++++-------- src/smpi/smpi_shared.cpp | 6 +++--- .../macro-partial-shared-communication.c | 8 ++++---- .../macro-partial-shared/macro-partial-shared.c | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index f81d6fcf8f..c29f0cadc0 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -104,22 +104,22 @@ void smpi_comm_set_copy_data_callback(void (*callback) (smx_activity_t, void*, s smpi_comm_copy_data_callback = callback; } -void print(std::vector> vec) { +static void print(std::vector> vec) { fprintf(stderr, "{"); for(auto elt: vec) { - fprintf(stderr, "(0x%x, 0x%x),", elt.first, elt.second); + fprintf(stderr, "(0x%lx, 0x%lx),", elt.first, elt.second); } - stderr, fprintf(stderr, "}\n"); + fprintf(stderr, "}\n"); } -void memcpy_private(void *dest, const void *src, size_t n, std::vector> &private_blocks) { +static void memcpy_private(void *dest, const void *src, size_t n, std::vector> &private_blocks) { for(auto block : private_blocks) { memcpy((uint8_t*)dest+block.first, (uint8_t*)src+block.first, block.second-block.first); } } -void check_blocks(std::vector> &private_blocks, size_t buff_size) { +static void check_blocks(std::vector> &private_blocks, size_t buff_size) { for(auto block : private_blocks) { - xbt_assert(block.first >= 0 && block.second <= buff_size, "Oops, bug in shared malloc."); + xbt_assert(block.first <= block.second && block.second <= buff_size, "Oops, bug in shared malloc."); } } @@ -131,7 +131,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b std::vector> src_private_blocks; std::vector> dst_private_blocks; XBT_DEBUG("Copy the data over"); - if(src_shared=smpi_is_shared(buff, src_private_blocks, &src_offset)) { + if((src_shared=smpi_is_shared(buff, src_private_blocks, &src_offset))) { XBT_DEBUG("Sender %p is shared. Let's ignore it.", buff); src_private_blocks = shift_and_frame_private_blocks(src_private_blocks, src_offset, buff_size); } @@ -139,7 +139,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b src_private_blocks.clear(); src_private_blocks.push_back(std::make_pair(0, buff_size)); } - if(dst_shared=smpi_is_shared((char*)comm->dst_buff, dst_private_blocks, &dst_offset)) { + if((dst_shared=smpi_is_shared((char*)comm->dst_buff, dst_private_blocks, &dst_offset))) { XBT_DEBUG("Receiver %p is shared. Let's ignore it.", (char*)comm->dst_buff); dst_private_blocks = shift_and_frame_private_blocks(dst_private_blocks, dst_offset, buff_size); } diff --git a/src/smpi/smpi_shared.cpp b/src/smpi/smpi_shared.cpp index e6b83111a9..39a3369d54 100644 --- a/src/smpi/smpi_shared.cpp +++ b/src/smpi/smpi_shared.cpp @@ -37,6 +37,7 @@ #include "private.h" #include "private.hpp" +#include "smpi/smpi_shared_malloc.hpp" #include "xbt/dict.h" #include @@ -169,7 +170,7 @@ static void* shm_map(int fd, size_t size, shared_data_key_type* data) { return mem; } -void *smpi_shared_malloc_local(size_t size, const char *file, int line) +static void *smpi_shared_malloc_local(size_t size, const char *file, int line) { void* mem; smpi_source_location loc(file, line); @@ -238,7 +239,6 @@ void *smpi_shared_malloc_global__(size_t size, const char *file, int line, size_ for(int i_block = 0; i_block < nb_shared_blocks; i_block ++) { size_t start_offset = shared_block_offsets[2*i_block]; size_t stop_offset = shared_block_offsets[2*i_block+1]; - xbt_assert(0 <= start_offset, "start_offset (%lu) should be greater than 0", start_offset); xbt_assert(start_offset < stop_offset, "start_offset (%lu) should be lower than stop offset (%lu)", start_offset, stop_offset); xbt_assert(stop_offset <= size, "stop_offset (%lu) should be lower than size (%lu)", stop_offset, size); if(i_block < nb_shared_blocks-1) @@ -314,7 +314,7 @@ void *smpi_shared_malloc_global__(size_t size, const char *file, int line, size_ * Even indices are the start offsets (included), odd indices are the stop offsets (excluded). * For instance, if shared_block_offsets == {27, 42}, then the elements mem[27], mem[28], ..., mem[41] are shared. The others are not. */ -void *smpi_shared_malloc_global(size_t size, const char *file, int line, size_t *shared_block_offsets=NULL, int nb_shared_blocks=-1) { +static void *smpi_shared_malloc_global(size_t size, const char *file, int line, size_t *shared_block_offsets=NULL, int nb_shared_blocks=-1) { size_t tmp_shared_block_offsets[2]; if(nb_shared_blocks == -1) { nb_shared_blocks = 1; diff --git a/teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.c b/teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.c index 440a41e3af..afed268325 100644 --- a/teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.c +++ b/teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.c @@ -11,14 +11,14 @@ #include // Set the elements between buf[start] and buf[stop-1] to (i+value)%256 -void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) { +static void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) { for(size_t i = start; i < stop; i++) { buf[i] = (i+value)%256; } } // Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1]. -int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { +static int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { size_t occ = 0; for(size_t i = start ; i < stop ; i++) { if(buf[i] == (i+value)%256) { @@ -29,13 +29,13 @@ int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { } // Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256. -int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { +static int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { size_t occ = count_all(buf, start, stop, value); return occ == stop-start; } // Return true iff "enough" elements are equal to (i+value)%256 between buf[start] and buf[stop-1]. -int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) { +static int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) { int page_size = 0x1000; size_t size = stop-start; if(size <= 2*page_size) // we are not sure to have a whole page that is shared diff --git a/teshsuite/smpi/macro-partial-shared/macro-partial-shared.c b/teshsuite/smpi/macro-partial-shared/macro-partial-shared.c index 18aafd86e8..305810ecc9 100644 --- a/teshsuite/smpi/macro-partial-shared/macro-partial-shared.c +++ b/teshsuite/smpi/macro-partial-shared/macro-partial-shared.c @@ -10,14 +10,14 @@ #include // Set the elements between buf[start] and buf[stop-1] to (i+value)%256 -void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) { +static void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) { for(size_t i = start; i < stop; i++) { buf[i] = (i+value)%256; } } // Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1]. -int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { +static int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { size_t occ = 0; for(size_t i = start ; i < stop ; i++) { if(buf[i] == (i+value)%256) { @@ -28,13 +28,13 @@ int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { } // Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256. -int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { +static int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) { size_t occ = count_all(buf, start, stop, value); return occ == stop-start; } // Return true iff "enough" elements are equal to (i+value)%256 between buf[start] and buf[stop-1]. -int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) { +static int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) { int page_size = 0x1000; size_t size = stop-start; if(size <= 2*page_size) // we are not sure to have a whole page that is shared -- 2.20.1