diff options
author | Daniel Neus <[email protected]> | 2016-01-09 12:37:13 +0100 |
---|---|---|
committer | Daniel Neus <[email protected]> | 2016-01-09 12:37:13 +0100 |
commit | f391635f202cf6f83539bd69688975a30f5f874f (patch) | |
tree | 206459e94ab379ba18a8e8035b1855327aa02126 /src/lib/utils | |
parent | 52afcc69d97621e5a3880798d7814a474e71c03b (diff) | |
parent | 791b3dc9947a94d35e6d54b274b0512fb0ebd09c (diff) |
Merge remote-tracking branch 'remotes/github/master' into noreturn
# Conflicts:
# src/build-data/cc/gcc.txt
Diffstat (limited to 'src/lib/utils')
-rw-r--r-- | src/lib/utils/data_src.cpp | 80 | ||||
-rw-r--r-- | src/lib/utils/data_src.h | 22 | ||||
-rw-r--r-- | src/lib/utils/datastor/datastor.cpp | 12 | ||||
-rw-r--r-- | src/lib/utils/datastor/datastor.h | 2 | ||||
-rw-r--r-- | src/lib/utils/dyn_load/dyn_load.cpp | 28 | ||||
-rw-r--r-- | src/lib/utils/dyn_load/dyn_load.h | 4 | ||||
-rw-r--r-- | src/lib/utils/simd/simd_sse2/simd_sse2.h | 60 |
7 files changed, 104 insertions, 104 deletions
diff --git a/src/lib/utils/data_src.cpp b/src/lib/utils/data_src.cpp index b79f83d40..fd1f118e0 100644 --- a/src/lib/utils/data_src.cpp +++ b/src/lib/utils/data_src.cpp @@ -55,15 +55,15 @@ size_t DataSource::discard_next(size_t n) */ size_t DataSource_Memory::read(byte out[], size_t length) { - size_t got = std::min<size_t>(source.size() - offset, length); - copy_mem(out, source.data() + offset, got); - offset += got; + size_t got = std::min<size_t>(m_source.size() - m_offset, length); + copy_mem(out, m_source.data() + m_offset, got); + m_offset += got; return got; } bool DataSource_Memory::check_available(size_t n) { - return (n <= (source.size() - offset)); + return (n <= (m_source.size() - m_offset)); } /* @@ -72,11 +72,11 @@ bool DataSource_Memory::check_available(size_t n) size_t DataSource_Memory::peek(byte out[], size_t length, size_t peek_offset) const { - const size_t bytes_left = source.size() - offset; + const size_t bytes_left = m_source.size() - m_offset; if(peek_offset >= bytes_left) return 0; size_t got = std::min(bytes_left - peek_offset, length); - copy_mem(out, &source[offset + peek_offset], got); + copy_mem(out, &m_source[m_offset + peek_offset], got); return got; } @@ -85,18 +85,18 @@ size_t DataSource_Memory::peek(byte out[], size_t length, */ bool DataSource_Memory::end_of_data() const { - return (offset == source.size()); + return (m_offset == m_source.size()); } /* * DataSource_Memory Constructor */ DataSource_Memory::DataSource_Memory(const std::string& in) : - source(reinterpret_cast<const byte*>(in.data()), + m_source(reinterpret_cast<const byte*>(in.data()), reinterpret_cast<const byte*>(in.data()) + in.length()), - offset(0) + m_offset(0) { - offset = 0; + m_offset = 0; } /* @@ -104,21 +104,21 @@ DataSource_Memory::DataSource_Memory(const std::string& in) : */ size_t DataSource_Stream::read(byte out[], size_t length) { - source.read(reinterpret_cast<char*>(out), length); - if(source.bad()) + m_source.read(reinterpret_cast<char*>(out), length); + if(m_source.bad()) throw Stream_IO_Error("DataSource_Stream::read: Source failure"); - size_t got = source.gcount(); - total_read += got; + size_t got = m_source.gcount(); + m_total_read += got; return got; } bool DataSource_Stream::check_available(size_t n) { - const std::streampos orig_pos = source.tellg(); - source.seekg(0, std::ios::end); - const size_t avail = source.tellg() - orig_pos; - source.seekg(orig_pos); + const std::streampos orig_pos = m_source.tellg(); + m_source.seekg(0, std::ios::end); + const size_t avail = m_source.tellg() - orig_pos; + m_source.seekg(orig_pos); return (avail >= n); } @@ -135,23 +135,23 @@ size_t DataSource_Stream::peek(byte out[], size_t length, size_t offset) const if(offset) { secure_vector<byte> buf(offset); - source.read(reinterpret_cast<char*>(buf.data()), buf.size()); - if(source.bad()) + m_source.read(reinterpret_cast<char*>(buf.data()), buf.size()); + if(m_source.bad()) throw Stream_IO_Error("DataSource_Stream::peek: Source failure"); - got = source.gcount(); + got = m_source.gcount(); } if(got == offset) { - source.read(reinterpret_cast<char*>(out), length); - if(source.bad()) + m_source.read(reinterpret_cast<char*>(out), length); + if(m_source.bad()) throw Stream_IO_Error("DataSource_Stream::peek: Source failure"); - got = source.gcount(); + got = m_source.gcount(); } - if(source.eof()) - source.clear(); - source.seekg(total_read, std::ios::beg); + if(m_source.eof()) + m_source.clear(); + m_source.seekg(m_total_read, std::ios::beg); return got; } @@ -161,7 +161,7 @@ size_t DataSource_Stream::peek(byte out[], size_t length, size_t offset) const */ bool DataSource_Stream::end_of_data() const { - return (!source.good()); + return (!m_source.good()); } /* @@ -169,7 +169,7 @@ bool DataSource_Stream::end_of_data() const */ std::string DataSource_Stream::id() const { - return identifier; + return m_identifier; } /* @@ -177,15 +177,15 @@ std::string DataSource_Stream::id() const */ DataSource_Stream::DataSource_Stream(const std::string& path, bool use_binary) : - identifier(path), - source_p(new std::ifstream(path, + m_identifier(path), + m_source_p(new std::ifstream(path, use_binary ? std::ios::binary : std::ios::in)), - source(*source_p), - total_read(0) + m_source(*m_source_p), + m_total_read(0) { - if(!source.good()) + if(!m_source.good()) { - delete source_p; + delete m_source_p; throw Stream_IO_Error("DataSource: Failure opening file " + path); } } @@ -195,10 +195,10 @@ DataSource_Stream::DataSource_Stream(const std::string& path, */ DataSource_Stream::DataSource_Stream(std::istream& in, const std::string& name) : - identifier(name), - source_p(nullptr), - source(in), - total_read(0) + m_identifier(name), + m_source_p(nullptr), + m_source(in), + m_total_read(0) { } @@ -207,7 +207,7 @@ DataSource_Stream::DataSource_Stream(std::istream& in, */ DataSource_Stream::~DataSource_Stream() { - delete source_p; + delete m_source_p; } } diff --git a/src/lib/utils/data_src.h b/src/lib/utils/data_src.h index 2b6998448..0a6ce0a8c 100644 --- a/src/lib/utils/data_src.h +++ b/src/lib/utils/data_src.h @@ -116,26 +116,26 @@ class BOTAN_DLL DataSource_Memory : public DataSource * @param length the length of the byte array */ DataSource_Memory(const byte in[], size_t length) : - source(in, in + length), offset(0) {} + m_source(in, in + length), m_offset(0) {} /** * Construct a memory source that reads from a secure_vector * @param in the MemoryRegion to read from */ DataSource_Memory(const secure_vector<byte>& in) : - source(in), offset(0) {} + m_source(in), m_offset(0) {} /** * Construct a memory source that reads from a std::vector * @param in the MemoryRegion to read from */ DataSource_Memory(const std::vector<byte>& in) : - source(in.begin(), in.end()), offset(0) {} + m_source(in.begin(), in.end()), m_offset(0) {} - size_t get_bytes_read() const override { return offset; } + size_t get_bytes_read() const override { return m_offset; } private: - secure_vector<byte> source; - size_t offset; + secure_vector<byte> m_source; + size_t m_offset; }; /** @@ -166,13 +166,13 @@ class BOTAN_DLL DataSource_Stream : public DataSource ~DataSource_Stream(); - size_t get_bytes_read() const override { return total_read; } + size_t get_bytes_read() const override { return m_total_read; } private: - const std::string identifier; + const std::string m_identifier; - std::istream* source_p; - std::istream& source; - size_t total_read; + std::istream* m_source_p; + std::istream& m_source; + size_t m_total_read; }; } diff --git a/src/lib/utils/datastor/datastor.cpp b/src/lib/utils/datastor/datastor.cpp index 69c1bf453..6f1b71082 100644 --- a/src/lib/utils/datastor/datastor.cpp +++ b/src/lib/utils/datastor/datastor.cpp @@ -18,7 +18,7 @@ namespace Botan { */ bool Data_Store::operator==(const Data_Store& other) const { - return (contents == other.contents); + return (m_contents == other.m_contents); } /* @@ -26,7 +26,7 @@ bool Data_Store::operator==(const Data_Store& other) const */ bool Data_Store::has_value(const std::string& key) const { - return (contents.lower_bound(key) != contents.end()); + return (m_contents.lower_bound(key) != m_contents.end()); } /* @@ -37,7 +37,7 @@ std::multimap<std::string, std::string> Data_Store::search_for( { std::multimap<std::string, std::string> out; - for(auto i = contents.begin(); i != contents.end(); ++i) + for(auto i = m_contents.begin(); i != m_contents.end(); ++i) if(predicate(i->first, i->second)) out.insert(std::make_pair(i->first, i->second)); @@ -50,7 +50,7 @@ std::multimap<std::string, std::string> Data_Store::search_for( std::vector<std::string> Data_Store::get(const std::string& looking_for) const { std::vector<std::string> out; - auto range = contents.equal_range(looking_for); + auto range = m_contents.equal_range(looking_for); for(auto i = range.first; i != range.second; ++i) out.push_back(i->second); return out; @@ -125,7 +125,7 @@ u32bit Data_Store::get1_u32bit(const std::string& key, */ void Data_Store::add(const std::string& key, const std::string& val) { - multimap_insert(contents, key, val); + multimap_insert(m_contents, key, val); } /* @@ -157,7 +157,7 @@ void Data_Store::add(const std::multimap<std::string, std::string>& in) std::multimap<std::string, std::string>::const_iterator i = in.begin(); while(i != in.end()) { - contents.insert(*i); + m_contents.insert(*i); ++i; } } diff --git a/src/lib/utils/datastor/datastor.h b/src/lib/utils/datastor/datastor.h index 66bb0e650..3b25e1fe4 100644 --- a/src/lib/utils/datastor/datastor.h +++ b/src/lib/utils/datastor/datastor.h @@ -49,7 +49,7 @@ class BOTAN_DLL Data_Store void add(const std::string&, const secure_vector<byte>&); void add(const std::string&, const std::vector<byte>&); private: - std::multimap<std::string, std::string> contents; + std::multimap<std::string, std::string> m_contents; }; } diff --git a/src/lib/utils/dyn_load/dyn_load.cpp b/src/lib/utils/dyn_load/dyn_load.cpp index 3448acf6a..c0795942b 100644 --- a/src/lib/utils/dyn_load/dyn_load.cpp +++ b/src/lib/utils/dyn_load/dyn_load.cpp @@ -30,31 +30,31 @@ void raise_runtime_loader_exception(const std::string& lib_name, Dynamically_Loaded_Library::Dynamically_Loaded_Library( const std::string& library) : - lib_name(library), lib(nullptr) + m_lib_name(library), m_lib(nullptr) { #if defined(BOTAN_TARGET_OS_HAS_DLOPEN) - lib = ::dlopen(lib_name.c_str(), RTLD_LAZY); + m_lib = ::dlopen(m_lib_name.c_str(), RTLD_LAZY); - if(!lib) - raise_runtime_loader_exception(lib_name, dlerror()); + if(!m_lib) + raise_runtime_loader_exception(m_lib_name, dlerror()); #elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY) - lib = ::LoadLibraryA(lib_name.c_str()); + m_lib = ::LoadLibraryA(m_lib_name.c_str()); - if(!lib) - raise_runtime_loader_exception(lib_name, "LoadLibrary failed"); + if(!m_lib) + raise_runtime_loader_exception(m_lib_name, "LoadLibrary failed"); #endif - if(!lib) - raise_runtime_loader_exception(lib_name, "Dynamic load not supported"); + if(!m_lib) + raise_runtime_loader_exception(m_lib_name, "Dynamic load not supported"); } Dynamically_Loaded_Library::~Dynamically_Loaded_Library() { #if defined(BOTAN_TARGET_OS_HAS_DLOPEN) - ::dlclose(lib); + ::dlclose(m_lib); #elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY) - ::FreeLibrary((HMODULE)lib); + ::FreeLibrary((HMODULE)m_lib); #endif } @@ -63,15 +63,15 @@ void* Dynamically_Loaded_Library::resolve_symbol(const std::string& symbol) void* addr = nullptr; #if defined(BOTAN_TARGET_OS_HAS_DLOPEN) - addr = ::dlsym(lib, symbol.c_str()); + addr = ::dlsym(m_lib, symbol.c_str()); #elif defined(BOTAN_TARGET_OS_HAS_LOADLIBRARY) - addr = reinterpret_cast<void*>(::GetProcAddress((HMODULE)lib, + addr = reinterpret_cast<void*>(::GetProcAddress((HMODULE)m_lib, symbol.c_str())); #endif if(!addr) throw Exception("Failed to resolve symbol " + symbol + - " in " + lib_name); + " in " + m_lib_name); return addr; } diff --git a/src/lib/utils/dyn_load/dyn_load.h b/src/lib/utils/dyn_load/dyn_load.h index 32227f76f..7a9f4a83c 100644 --- a/src/lib/utils/dyn_load/dyn_load.h +++ b/src/lib/utils/dyn_load/dyn_load.h @@ -58,8 +58,8 @@ class Dynamically_Loaded_Library Dynamically_Loaded_Library(const Dynamically_Loaded_Library&); Dynamically_Loaded_Library& operator=(const Dynamically_Loaded_Library&); - std::string lib_name; - void* lib; + std::string m_lib_name; + void* m_lib; }; } diff --git a/src/lib/utils/simd/simd_sse2/simd_sse2.h b/src/lib/utils/simd/simd_sse2/simd_sse2.h index 9e85bd45b..1757b5976 100644 --- a/src/lib/utils/simd/simd_sse2/simd_sse2.h +++ b/src/lib/utils/simd/simd_sse2/simd_sse2.h @@ -20,17 +20,17 @@ class SIMD_SSE2 public: SIMD_SSE2(const u32bit B[4]) { - reg = _mm_loadu_si128(reinterpret_cast<const __m128i*>(B)); + m_reg = _mm_loadu_si128(reinterpret_cast<const __m128i*>(B)); } SIMD_SSE2(u32bit B0, u32bit B1, u32bit B2, u32bit B3) { - reg = _mm_set_epi32(B0, B1, B2, B3); + m_reg = _mm_set_epi32(B0, B1, B2, B3); } SIMD_SSE2(u32bit B) { - reg = _mm_set1_epi32(B); + m_reg = _mm_set1_epi32(B); } static SIMD_SSE2 load_le(const void* in) @@ -45,7 +45,7 @@ class SIMD_SSE2 void store_le(byte out[]) const { - _mm_storeu_si128(reinterpret_cast<__m128i*>(out), reg); + _mm_storeu_si128(reinterpret_cast<__m128i*>(out), m_reg); } void store_be(byte out[]) const @@ -55,8 +55,8 @@ class SIMD_SSE2 void rotate_left(size_t rot) { - reg = _mm_or_si128(_mm_slli_epi32(reg, static_cast<int>(rot)), - _mm_srli_epi32(reg, static_cast<int>(32-rot))); + m_reg = _mm_or_si128(_mm_slli_epi32(m_reg, static_cast<int>(rot)), + _mm_srli_epi32(m_reg, static_cast<int>(32-rot))); } void rotate_right(size_t rot) @@ -66,73 +66,73 @@ class SIMD_SSE2 void operator+=(const SIMD_SSE2& other) { - reg = _mm_add_epi32(reg, other.reg); + m_reg = _mm_add_epi32(m_reg, other.m_reg); } SIMD_SSE2 operator+(const SIMD_SSE2& other) const { - return _mm_add_epi32(reg, other.reg); + return _mm_add_epi32(m_reg, other.m_reg); } void operator-=(const SIMD_SSE2& other) { - reg = _mm_sub_epi32(reg, other.reg); + m_reg = _mm_sub_epi32(m_reg, other.m_reg); } SIMD_SSE2 operator-(const SIMD_SSE2& other) const { - return _mm_sub_epi32(reg, other.reg); + return _mm_sub_epi32(m_reg, other.m_reg); } void operator^=(const SIMD_SSE2& other) { - reg = _mm_xor_si128(reg, other.reg); + m_reg = _mm_xor_si128(m_reg, other.m_reg); } SIMD_SSE2 operator^(const SIMD_SSE2& other) const { - return _mm_xor_si128(reg, other.reg); + return _mm_xor_si128(m_reg, other.m_reg); } void operator|=(const SIMD_SSE2& other) { - reg = _mm_or_si128(reg, other.reg); + m_reg = _mm_or_si128(m_reg, other.m_reg); } SIMD_SSE2 operator&(const SIMD_SSE2& other) { - return _mm_and_si128(reg, other.reg); + return _mm_and_si128(m_reg, other.m_reg); } void operator&=(const SIMD_SSE2& other) { - reg = _mm_and_si128(reg, other.reg); + m_reg = _mm_and_si128(m_reg, other.m_reg); } SIMD_SSE2 operator<<(size_t shift) const { - return _mm_slli_epi32(reg, static_cast<int>(shift)); + return _mm_slli_epi32(m_reg, static_cast<int>(shift)); } SIMD_SSE2 operator>>(size_t shift) const { - return _mm_srli_epi32(reg, static_cast<int>(shift)); + return _mm_srli_epi32(m_reg, static_cast<int>(shift)); } SIMD_SSE2 operator~() const { - return _mm_xor_si128(reg, _mm_set1_epi32(0xFFFFFFFF)); + return _mm_xor_si128(m_reg, _mm_set1_epi32(0xFFFFFFFF)); } // (~reg) & other SIMD_SSE2 andc(const SIMD_SSE2& other) { - return _mm_andnot_si128(reg, other.reg); + return _mm_andnot_si128(m_reg, other.m_reg); } SIMD_SSE2 bswap() const { - __m128i T = reg; + __m128i T = m_reg; T = _mm_shufflehi_epi16(T, _MM_SHUFFLE(2, 3, 0, 1)); T = _mm_shufflelo_epi16(T, _MM_SHUFFLE(2, 3, 0, 1)); @@ -144,20 +144,20 @@ class SIMD_SSE2 static void transpose(SIMD_SSE2& B0, SIMD_SSE2& B1, SIMD_SSE2& B2, SIMD_SSE2& B3) { - __m128i T0 = _mm_unpacklo_epi32(B0.reg, B1.reg); - __m128i T1 = _mm_unpacklo_epi32(B2.reg, B3.reg); - __m128i T2 = _mm_unpackhi_epi32(B0.reg, B1.reg); - __m128i T3 = _mm_unpackhi_epi32(B2.reg, B3.reg); - B0.reg = _mm_unpacklo_epi64(T0, T1); - B1.reg = _mm_unpackhi_epi64(T0, T1); - B2.reg = _mm_unpacklo_epi64(T2, T3); - B3.reg = _mm_unpackhi_epi64(T2, T3); + __m128i T0 = _mm_unpacklo_epi32(B0.m_reg, B1.m_reg); + __m128i T1 = _mm_unpacklo_epi32(B2.m_reg, B3.m_reg); + __m128i T2 = _mm_unpackhi_epi32(B0.m_reg, B1.m_reg); + __m128i T3 = _mm_unpackhi_epi32(B2.m_reg, B3.m_reg); + B0.m_reg = _mm_unpacklo_epi64(T0, T1); + B1.m_reg = _mm_unpackhi_epi64(T0, T1); + B2.m_reg = _mm_unpacklo_epi64(T2, T3); + B3.m_reg = _mm_unpackhi_epi64(T2, T3); } private: - SIMD_SSE2(__m128i in) { reg = in; } + SIMD_SSE2(__m128i in) { m_reg = in; } - __m128i reg; + __m128i m_reg; }; } |