Commit 078990a7 authored by Thibault Allançon's avatar Thibault Allançon

bricks: fix latest version compilation

This is the continuation of b1a28932 (the update commit), to fix GCC and
Spot related compilation issues with the 4.4.2 bricks version.

* spot/bricks/brick-bitlevel,
spot/bricks/brick-hash,
spot/bricks/brick-hashset,
spot/bricks/brick-min,
spot/bricks/brick-ptr,
spot/bricks/brick-shmem,
spot/bricks/brick-string,
spot/bricks/brick-trace: update here.
parent b1a28932
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
#pragma once #pragma once
#include <brick-assert> // FIX HERE: use #include "" instead of #include <>
#include "brick-assert"
#include <type_traits> #include <type_traits>
#include <limits> #include <limits>
...@@ -259,7 +260,8 @@ namespace brick::bitlevel ...@@ -259,7 +260,8 @@ namespace brick::bitlevel
return c.c; return c.c;
} }
uint32_t mixdown( uint64_t i ) /* due to Thomas Wang */ // FIX HERE: unused functions
/*uint32_t mixdown( uint64_t i ) // due to Thomas Wang
{ {
i = (~i) + (i << 18); i = (~i) + (i << 18);
i = i ^ (i >> 31); i = i ^ (i >> 31);
...@@ -273,7 +275,7 @@ namespace brick::bitlevel ...@@ -273,7 +275,7 @@ namespace brick::bitlevel
uint32_t mixdown( uint32_t a, uint32_t b ) uint32_t mixdown( uint32_t a, uint32_t b )
{ {
return mixdown( ( uint64_t( a ) << 32 ) | uint64_t( b ) ); return mixdown( ( uint64_t( a ) << 32 ) | uint64_t( b ) );
} }*/
} }
/* Fills `x` by bits up to the most si significant bit. Complexity is O(log n), /* Fills `x` by bits up to the most si significant bit. Complexity is O(log n),
...@@ -521,13 +523,14 @@ namespace brick::bitlevel ...@@ -521,13 +523,14 @@ namespace brick::bitlevel
return *this; \ return *this; \
} }
OP(+=); // FIX HERE: remove extra ';' (-pedantic)
OP(-=); OP(+=)
OP(*=); OP(-=)
OP(/=); OP(*=)
OP(%=); OP(/=)
OP(|=); OP(%=)
OP(&=); OP(|=)
OP(&=)
#undef OP #undef OP
}; };
}; };
......
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
#include <cstdint> #include <cstdint>
#include <array> #include <array>
#include <brick-assert> // FIX HERE: use #include "" instead of #include <>
#include <brick-trace> #include "brick-assert"
#include "brick-trace"
namespace brq::impl namespace brq::impl
{ {
...@@ -35,18 +36,19 @@ namespace brq::impl ...@@ -35,18 +36,19 @@ namespace brq::impl
static const uint64_t prime_5 = UINT64_C( 0xC060724A8424F345 ); static const uint64_t prime_5 = UINT64_C( 0xC060724A8424F345 );
static const uint64_t prime_6 = UINT64_C( 0xCB5AF53AE3AAAC31 ); static const uint64_t prime_6 = UINT64_C( 0xCB5AF53AE3AAAC31 );
[[gnu::always_inline]] static uint64_t rot64( uint64_t v, unsigned s ) // FIX HERE: add missing inline keyword
[[gnu::always_inline]] inline static uint64_t rot64( uint64_t v, unsigned s )
{ {
return ( v >> s ) | ( v << ( 64 - s ) ); return ( v >> s ) | ( v << ( 64 - s ) );
} }
[[gnu::always_inline]] static uint64_t mux64( uint64_t v, uint64_t prime ) [[gnu::always_inline]] inline static uint64_t mux64( uint64_t v, uint64_t prime )
{ {
__uint128_t r = __uint128_t( v ) * __uint128_t( prime ); __uint128_t r = __uint128_t( v ) * __uint128_t( prime );
return uint64_t( r >> 64 ) ^ uint64_t( r ); return uint64_t( r >> 64 ) ^ uint64_t( r );
} }
[[gnu::always_inline]] static uint64_t mix64( uint64_t v, uint64_t p ) /* xor-mul-xor */ [[gnu::always_inline]] inline static uint64_t mix64( uint64_t v, uint64_t p ) /* xor-mul-xor */
{ {
v *= p; v *= p;
return v ^ rot64( v, 41 ); return v ^ rot64( v, 41 );
......
...@@ -20,13 +20,14 @@ ...@@ -20,13 +20,14 @@
#pragma once #pragma once
#include <brick-hash> // FIX HERE: use #include "" instead of #include <>
#include <brick-ptr> #include "brick-hash"
#include <brick-shmem> #include "brick-ptr"
#include <brick-bitlevel> #include "brick-shmem"
#include <brick-assert> #include "brick-bitlevel"
#include <brick-trace> #include "brick-assert"
#include <brick-types> #include "brick-trace"
#include "brick-types"
#include <type_traits> #include <type_traits>
#include <set> #include <set>
...@@ -241,8 +242,9 @@ namespace brq::impl ...@@ -241,8 +242,9 @@ namespace brq::impl
template< typename T > template< typename T >
struct alignas( std::min( 16ul, sizeof( tagged< T > ) ) ) atomic_cell : cell_base< T > struct alignas( std::min( 16ul, sizeof( tagged< T > ) ) ) atomic_cell : cell_base< T >
{ {
using tagged = tagged< T >; // FIX HERE: remove name shadowing
using bare_value = typename tagged::Type; using taggedT = tagged< T >;
using bare_value = typename taggedT::Type;
using atomic_value = std::atomic< bare_value >; using atomic_value = std::atomic< bare_value >;
using pointer = const atomic_value *; using pointer = const atomic_value *;
using reference = const atomic_value &; using reference = const atomic_value &;
...@@ -262,8 +264,8 @@ namespace brq::impl ...@@ -262,8 +264,8 @@ namespace brq::impl
bool tombstone() const { return status() == 2; } bool tombstone() const { return status() == 2; }
pointer value() const { return &_value; } pointer value() const { return &_value; }
T fetch() const { return tagged::fetch( _value ); } T fetch() const { return taggedT::fetch( _value ); }
T copy() const { bare_value v = _value; v.tag( 0 ); return tagged::fetch( v ); } T copy() const { bare_value v = _value; v.tag( 0 ); return taggedT::fetch( v ); }
bool wait() { return !invalid(); } bool wait() { return !invalid(); }
bool match( hash64_t hash ) const { return _value.load().tag() == ( hashbits( hash ) | 3 ); } bool match( hash64_t hash ) const { return _value.load().tag() == ( hashbits( hash ) | 3 ); }
bool tombstone( hash64_t hash ) const { return _value.load().tag() == ( hashbits( hash ) | 2 ); } bool tombstone( hash64_t hash ) const { return _value.load().tag() == ( hashbits( hash ) | 2 ); }
...@@ -369,7 +371,8 @@ namespace brq::impl ...@@ -369,7 +371,8 @@ namespace brq::impl
brq::refcount_ptr< hash_table, true > next; brq::refcount_ptr< hash_table, true > next;
std::atomic< size_t > _size; std::atomic< size_t > _size;
std::atomic< ssize_t > to_rehash; std::atomic< ssize_t > to_rehash;
uint8_t _data[]; // FIX HERE: replace flexible array member with array of size 1
uint8_t _data[1];
Cell &data( int i = 0 ) { return reinterpret_cast< Cell * >( _data )[ i ]; } Cell &data( int i = 0 ) { return reinterpret_cast< Cell * >( _data )[ i ]; }
using value_type = typename Cell::value_type; using value_type = typename Cell::value_type;
...@@ -378,7 +381,8 @@ namespace brq::impl ...@@ -378,7 +381,8 @@ namespace brq::impl
using Lookup = std::pair< typename Cell::pointer, LookupTag >; using Lookup = std::pair< typename Cell::pointer, LookupTag >;
enum InsertMode { Rehash, Insert }; enum InsertMode { Rehash, Insert };
template< typename stream > // FIX HERE: fix recursive template depth exceeded
/*template< typename stream >
friend auto operator<<( stream &o, LookupTag t ) -> decltype( o << "" ) friend auto operator<<( stream &o, LookupTag t ) -> decltype( o << "" )
{ {
switch ( t ) switch ( t )
...@@ -388,7 +392,7 @@ namespace brq::impl ...@@ -388,7 +392,7 @@ namespace brq::impl
case Invalid: return o << "invalid"; case Invalid: return o << "invalid";
default: return o << int( t ); default: return o << int( t );
} }
} }*/
static void *operator new( size_t objsize, size_t cellcount ) static void *operator new( size_t objsize, size_t cellcount )
{ {
...@@ -398,6 +402,12 @@ namespace brq::impl ...@@ -398,6 +402,12 @@ namespace brq::impl
return rv; return rv;
} }
// FIX HERE: add missing delete operator
static void operator delete( void *memory )
{
free(memory);
}
hash_table( size_t size, ssize_t rehash ) hash_table( size_t size, ssize_t rehash )
: next( nullptr ), _size( size ), to_rehash( rehash ) : next( nullptr ), _size( size ), to_rehash( rehash )
{ {
...@@ -443,6 +453,8 @@ namespace brq::impl ...@@ -443,6 +453,8 @@ namespace brq::impl
ASSERT_EQ( mask | size(), mask + size() ); ASSERT_EQ( mask | size(), mask + size() );
Cell *tomb = nullptr; Cell *tomb = nullptr;
// FIX HERE: unused variable tomb if concurrent is set
(void)(tomb);
for ( unsigned i = 0; i < max; ++i ) for ( unsigned i = 0; i < max; ++i )
{ {
...@@ -477,19 +489,21 @@ namespace brq::impl ...@@ -477,19 +489,21 @@ namespace brq::impl
auto find_generic( const X &x, hash64_t h, F match ) auto find_generic( const X &x, hash64_t h, F match )
-> std::pair< decltype( match( std::declval< Cell & >(), x, h ) ), LookupTag > -> std::pair< decltype( match( std::declval< Cell & >(), x, h ) ), LookupTag >
{ {
// FIX HERE: explicit cast from nullptr to bool needed by GCC
const auto nil = (decltype( match( std::declval< Cell & >(), x, h ) )) nullptr;
const size_t mask = size() - 1; const size_t mask = size() - 1;
for ( size_t i = 0; i < max_chain; ++i ) for ( size_t i = 0; i < max_chain; ++i )
{ {
Cell &cell = data( index( h, i, mask ) ); Cell &cell = data( index( h, i, mask ) );
if ( cell.invalid() ) if ( cell.invalid() )
return { nullptr, Invalid }; return { nil, Invalid };
if ( cell.empty() ) if ( cell.empty() )
return { nullptr, Empty }; return { nil, Empty };
if ( auto v = match( cell, x, h ) ) if ( auto v = match( cell, x, h ) )
return { v, Found }; return { v, Found };
} }
return { nullptr, Empty }; return { nil, Empty };
} }
template< typename X, typename A > template< typename X, typename A >
...@@ -538,6 +552,12 @@ namespace brq::impl ...@@ -538,6 +552,12 @@ namespace brq::impl
brq::refcount_ptr< table > _table; brq::refcount_ptr< table > _table;
// FIX HERE: add missing delete operator
static void operator delete( void *memory )
{
free(memory);
}
size_t capacity() size_t capacity()
{ {
while ( await_update() ); while ( await_update() );
...@@ -646,6 +666,8 @@ namespace brq::impl ...@@ -646,6 +666,8 @@ namespace brq::impl
case A::Bury: buried = c.bury(); return true; case A::Bury: buried = c.bury(); return true;
case A::Done: buried = true; return true; case A::Done: buried = true; return true;
case A::Mismatch: return false; case A::Mismatch: return false;
// FIX HERE: add missing default
default: return false;
} }
}; };
...@@ -710,10 +732,12 @@ namespace brq::impl ...@@ -710,10 +732,12 @@ namespace brq::impl
if ( !result ) if ( !result )
{ {
string_builder err; // FIX HERE: replace string_builder with std::stringstream
// (prevent segfault)
std::stringstream err;
err << "hash table " << _table << " failed to rehash at size " << _table->size(); err << "hash table " << _table << " failed to rehash at size " << _table->size();
to.to_rehash.store( 0 ); /* prevent stalls and deadlocks */ to.to_rehash.store( 0 ); /* prevent stalls and deadlocks */
throw std::runtime_error( err.buffer() ); throw std::runtime_error( err.str() );
} }
} }
......
...@@ -189,7 +189,8 @@ namespace brq ...@@ -189,7 +189,8 @@ namespace brq
return (*this) << ( str ? std::string_view( str ) : "<nullptr>" ); return (*this) << ( str ? std::string_view( str ) : "<nullptr>" );
} }
template< typename C > // FIX HERE: fix recursive template depth exceeded (from brick-hashset)
/*template< typename C >
auto operator<<( const C &c ) noexcept auto operator<<( const C &c ) noexcept
-> std::enable_if_t< !std::is_convertible_v< C, std::string_view > && -> std::enable_if_t< !std::is_convertible_v< C, std::string_view > &&
!std::is_convertible_v< C, std::u32string_view >, !std::is_convertible_v< C, std::u32string_view >,
...@@ -199,7 +200,7 @@ namespace brq ...@@ -199,7 +200,7 @@ namespace brq
return *this << "[ " << *c << " ]"; return *this << "[ " << *c << " ]";
else else
return *this << "<null>"; return *this << "<null>";
} }*/
template< typename C > template< typename C >
auto operator<<( const C &c ) noexcept auto operator<<( const C &c ) noexcept
...@@ -230,7 +231,8 @@ namespace brq ...@@ -230,7 +231,8 @@ namespace brq
return f( *this ), *this; return f( *this ), *this;
} }
template< typename V > // FIX HERE: fix recursive template depth exceeded (from brick-hashset)
/*template< typename V >
auto operator<<( const V &val ) noexcept auto operator<<( const V &val ) noexcept
-> decltype( std::to_chars( _buffer, _buffer, val ), *this ) -> decltype( std::to_chars( _buffer, _buffer, val ), *this )
{ {
...@@ -248,7 +250,7 @@ namespace brq ...@@ -248,7 +250,7 @@ namespace brq
_offset = result.ptr - _buffer; _offset = result.ptr - _buffer;
_buffer[ _offset ] = 0; _buffer[ _offset ] = 0;
return *this; return *this;
} }*/
}; };
struct fallback struct fallback
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
#pragma once #pragma once
#include <brick-assert> // FIX HERE: use #include "" instead of #include <>
#include "brick-assert"
#include <atomic> #include <atomic>
namespace brq namespace brq
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
#pragma once #pragma once
#include <brick-assert> // FIX HERE: use #include "" instead of #include <>
#include "brick-assert"
#include <deque> #include <deque>
#include <iostream> #include <iostream>
#include <typeinfo> #include <typeinfo>
...@@ -91,12 +92,15 @@ struct Thread : T, ThreadBase ...@@ -91,12 +92,15 @@ struct Thread : T, ThreadBase
start(); start();
} }
virtual void start() // FIX HERE: add override
virtual void start() override
{ {
_thread.reset( new std::thread( [this]() { this->main(); } ) ); // FIX HERE: add noexcept
_thread.reset( new std::thread( [this]() noexcept { this->main(); } ) );
} }
virtual void stop() // FIX HERE: add override
virtual void stop() override
{ {
if ( _thread && _thread->joinable() ) if ( _thread && _thread->joinable() )
join(); join();
...@@ -666,7 +670,8 @@ std::future_status wait( I b, I e, F cleanup, steady_time until = later( 500 ) ) ...@@ -666,7 +670,8 @@ std::future_status wait( I b, I e, F cleanup, steady_time until = later( 500 ) )
return std::future_status::ready; return std::future_status::ready;
} }
return std::future_status::timeout; return std::future_status::timeout;
} catch ( ... ) { cleanup(); throw; }; // FIX HERE: remove extra ';' (-pedantic)
} catch ( ... ) { cleanup(); throw; }
} }
......
...@@ -99,7 +99,8 @@ namespace brq ...@@ -99,7 +99,8 @@ namespace brq
static mark_t mark; static mark_t mark;
static mark_t operator<<( string_builder &bld, mark_t ) { return mark_t( bld ); } // FIX HERE: fix recursive template depth exceeded (from brick-hashset)
/*static mark_t operator<<( string_builder &bld, mark_t ) { return mark_t( bld ); }
static pad operator<<( string_builder &bld, pad p ) { return pad( bld, p ); } static pad operator<<( string_builder &bld, pad p ) { return pad( bld, p ); }
static string_builder &operator<<( mark_t m, pad p ) static string_builder &operator<<( mark_t m, pad p )
...@@ -110,7 +111,7 @@ namespace brq ...@@ -110,7 +111,7 @@ namespace brq
static string_builder &operator<<( pad p, mark_t ) static string_builder &operator<<( pad p, mark_t )
{ {
return pad::write( *p.mark.b, p.width, p.mark.mark, p.ch, true ); return pad::write( *p.mark.b, p.width, p.mark.mark, p.ch, true );
} }*/
template< typename transform_t, typename stream_t > template< typename transform_t, typename stream_t >
struct string_transform struct string_transform
...@@ -332,7 +333,8 @@ namespace brq ...@@ -332,7 +333,8 @@ namespace brq
return parse_end == end ? parse_result() : no_parse( "error parsing ", s, " as a number" ); return parse_end == end ? parse_result() : no_parse( "error parsing ", s, " as a number" );
} }
static parse_result from_string( std::string_view s, bool &f ) // FIX HERE: fix recursive template depth exceeded (from brick-hashset)
/*static parse_result from_string( std::string_view s, bool &f )
{ {
if ( s == "yes" || s == "true" || s == "1" ) if ( s == "yes" || s == "true" || s == "1" )
{ {
...@@ -353,7 +355,7 @@ namespace brq ...@@ -353,7 +355,7 @@ namespace brq
{ {
v = s; v = s;
return {}; return {};
} }*/
template< typename container > template< typename container >
auto from_string( std::string_view s, container &c ) -> decltype( from_string( s, c.back() ) ) auto from_string( std::string_view s, container &c ) -> decltype( from_string( s, c.back() ) )
......
...@@ -70,7 +70,8 @@ ...@@ -70,7 +70,8 @@
#define TRACE(...) ::brq::trace_fn< true >( 3, BRICK_LOCATION( "" ), __VA_ARGS__ ) #define TRACE(...) ::brq::trace_fn< true >( 3, BRICK_LOCATION( "" ), __VA_ARGS__ )
#define NOISE(...) ::brq::trace_fn< true >( 4, BRICK_LOCATION( "" ), __VA_ARGS__ ) #define NOISE(...) ::brq::trace_fn< true >( 4, BRICK_LOCATION( "" ), __VA_ARGS__ )
#endif #endif
#define DEBUG(...) ::brq::trace_fn< false >( 2, BRICK_LOCATION( "" ), __VA_ARGS__ ) // FIX HERE: DEBUG already defined in spot
//#define DEBUG(...) ::brq::trace_fn< false >( 2, BRICK_LOCATION( "" ), __VA_ARGS__ )
#define INFO(...) ::brq::trace_fn< false >( 1, BRICK_LOCATION( "" ), __VA_ARGS__ ) #define INFO(...) ::brq::trace_fn< false >( 1, BRICK_LOCATION( "" ), __VA_ARGS__ )
#define ERROR(...) ::brq::trace_fn< false >( 0, BRICK_LOCATION( "" ), __VA_ARGS__ ) #define ERROR(...) ::brq::trace_fn< false >( 0, BRICK_LOCATION( "" ), __VA_ARGS__ )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment