mirror of
https://github.com/vimpunk/mio.git
synced 2025-12-06 16:57:01 +08:00
silencing -Wconversion and -Wsign-conversion warnings
This commit is contained in:
parent
565badb03f
commit
7fa954bdde
@ -26,6 +26,8 @@
|
|||||||
#include "mio/detail/string_util.hpp"
|
#include "mio/detail/string_util.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
@ -155,7 +157,7 @@ inline size_t query_file_size(file_handle_type handle, std::error_code& error)
|
|||||||
error = detail::last_error();
|
error = detail::last_error();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return sbuf.st_size;
|
return static_cast<size_t>(sbuf.st_size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +174,7 @@ struct mmap_context
|
|||||||
inline mmap_context memory_map(const file_handle_type file_handle, const int64_t offset,
|
inline mmap_context memory_map(const file_handle_type file_handle, const int64_t offset,
|
||||||
const int64_t length, const access_mode mode, std::error_code& error)
|
const int64_t length, const access_mode mode, std::error_code& error)
|
||||||
{
|
{
|
||||||
const int64_t aligned_offset = make_offset_page_aligned(offset);
|
const int64_t aligned_offset = static_cast<int64_t>(make_offset_page_aligned(static_cast<size_t>(offset)));
|
||||||
const int64_t length_to_map = offset - aligned_offset + length;
|
const int64_t length_to_map = offset - aligned_offset + length;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const int64_t max_file_size = offset + length;
|
const int64_t max_file_size = offset + length;
|
||||||
@ -204,7 +206,7 @@ inline mmap_context memory_map(const file_handle_type file_handle, const int64_t
|
|||||||
#else // POSIX
|
#else // POSIX
|
||||||
char* mapping_start = static_cast<char*>(::mmap(
|
char* mapping_start = static_cast<char*>(::mmap(
|
||||||
0, // Don't give hint as to where to map.
|
0, // Don't give hint as to where to map.
|
||||||
length_to_map,
|
static_cast<size_t>(length_to_map),
|
||||||
mode == access_mode::read ? PROT_READ : PROT_READ | PROT_WRITE,
|
mode == access_mode::read ? PROT_READ : PROT_READ | PROT_WRITE,
|
||||||
MAP_SHARED,
|
MAP_SHARED,
|
||||||
file_handle,
|
file_handle,
|
||||||
@ -345,8 +347,8 @@ void basic_mmap<AccessMode, ByteT>::map(const handle_type handle,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ctx = detail::memory_map(handle, offset,
|
const auto ctx = detail::memory_map(handle, static_cast<int64_t>(offset),
|
||||||
length == map_entire_file ? (file_size - offset) : length,
|
static_cast<int64_t>(length == map_entire_file ? (file_size - offset) : length),
|
||||||
AccessMode, error);
|
AccessMode, error);
|
||||||
if(!error)
|
if(!error)
|
||||||
{
|
{
|
||||||
@ -359,8 +361,8 @@ void basic_mmap<AccessMode, ByteT>::map(const handle_type handle,
|
|||||||
file_handle_ = handle;
|
file_handle_ = handle;
|
||||||
is_handle_internal_ = false;
|
is_handle_internal_ = false;
|
||||||
data_ = reinterpret_cast<pointer>(ctx.data);
|
data_ = reinterpret_cast<pointer>(ctx.data);
|
||||||
length_ = ctx.length;
|
length_ = static_cast<size_t>(ctx.length);
|
||||||
mapped_length_ = ctx.mapped_length;
|
mapped_length_ = static_cast<size_t>(ctx.mapped_length);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
file_mapping_handle_ = ctx.file_mapping_handle;
|
file_mapping_handle_ = ctx.file_mapping_handle;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#ifndef MIO_PAGE_HEADER
|
#ifndef MIO_PAGE_HEADER
|
||||||
#define MIO_PAGE_HEADER
|
#define MIO_PAGE_HEADER
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#else
|
#else
|
||||||
@ -48,7 +49,7 @@ enum class access_mode
|
|||||||
*/
|
*/
|
||||||
inline size_t page_size()
|
inline size_t page_size()
|
||||||
{
|
{
|
||||||
static const size_t page_size = []
|
static const size_t page_size = static_cast<size_t>([]
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SYSTEM_INFO SystemInfo;
|
SYSTEM_INFO SystemInfo;
|
||||||
@ -57,7 +58,7 @@ inline size_t page_size()
|
|||||||
#else
|
#else
|
||||||
return sysconf(_SC_PAGE_SIZE);
|
return sysconf(_SC_PAGE_SIZE);
|
||||||
#endif
|
#endif
|
||||||
}();
|
}());
|
||||||
return page_size;
|
return page_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user