16#include <zypp/base/Logger.h>
17#include <zypp/base/Exception.h>
18#include <zypp/base/NonCopyable.h>
19#include <zypp/base/Hash.h>
128 {
return ! ( lhs == rhs ); }
152 #define DEF_BUILTIN(A) \
153 namespace { static inline const IdString & a_##A () { static IdString _str(#A); return _str; } } \
154 const Arch Arch_##A( a_##A() )
252 typedef std::unordered_set<CompatEntry> Set;
253 typedef Set::iterator iterator;
254 typedef Set::const_iterator const_iterator;
257 static ArchCompatSet & instance()
259 static ArchCompatSet _instance;
266 const Arch::CompatEntry & assertDef(
const std::string & archStr_r )
267 {
return *
_compatSet.insert( Arch::CompatEntry( archStr_r ) ).first; }
269 const Arch::CompatEntry & assertDef( IdString archStr_r )
270 {
return *
_compatSet.insert( Arch::CompatEntry( archStr_r ) ).first; }
272 const_iterator begin()
const
275 const_iterator end()
const
280 int operator()(
const CompatEntry & lhs,
const CompatEntry & rhs )
const
281 {
return lhs._idBit.value() < rhs._idBit.value(); }
284 std::ostream &
dumpOn( std::ostream &
str )
const
286 str <<
"ArchCompatSet:";
288 ov.sort( DumpOnCompare() );
289 for_( it, ov.begin(), ov.end() )
291 str << endl <<
' ' << *it;
303 _compatSet.insert( Arch::CompatEntry( a_noarch(), 0 ) );
310 defCompatibleWith( a_i386(), a_noarch() );
311 defCompatibleWith( a_i486(), a_noarch(),a_i386() );
312 defCompatibleWith( a_i586(), a_noarch(),a_i386(),a_i486() );
313 defCompatibleWith( a_i686(), a_noarch(),a_i386(),a_i486(),a_i586() );
314 defCompatibleWith( a_athlon(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686() );
315 defCompatibleWith( a_x86_64(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_athlon() );
316 defCompatibleWith( a_x86_64_v2(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_athlon(),a_x86_64() );
317 defCompatibleWith( a_x86_64_v3(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_athlon(),a_x86_64(),a_x86_64_v2() );
318 defCompatibleWith( a_x86_64_v4(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_athlon(),a_x86_64(),a_x86_64_v2(),a_x86_64_v3() );
320 defCompatibleWith( a_pentium3(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686() );
321 defCompatibleWith( a_pentium4(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686(),a_pentium3() );
323 defCompatibleWith( a_ia64(), a_noarch(),a_i386(),a_i486(),a_i586(),a_i686() );
325 defCompatibleWith( a_s390(), a_noarch() );
326 defCompatibleWith( a_s390x(), a_noarch(),a_s390() );
328 defCompatibleWith( a_ppc(), a_noarch() );
329 defCompatibleWith( a_ppc64(), a_noarch(),a_ppc() );
330 defCompatibleWith( a_ppc64p7(), a_noarch(),a_ppc(),a_ppc64() );
332 defCompatibleWith( a_ppc64le(), a_noarch() );
334 defCompatibleWith( a_alpha(), a_noarch() );
335 defCompatibleWith( a_alphaev5(), a_noarch(),a_alpha() );
336 defCompatibleWith( a_alphaev56(), a_noarch(),a_alpha(),a_alphaev5() );
337 defCompatibleWith( a_alphapca56(), a_noarch(),a_alpha(),a_alphaev5(),a_alphaev56() );
338 defCompatibleWith( a_alphaev6(), a_noarch(),a_alpha(),a_alphaev5(),a_alphaev56(),a_alphapca56() );
339 defCompatibleWith( a_alphaev67(), a_noarch(),a_alpha(),a_alphaev5(),a_alphaev56(),a_alphapca56(),a_alphaev6() );
341 defCompatibleWith( a_sparc(), a_noarch() );
342 defCompatibleWith( a_sparcv8(), a_noarch(),a_sparc() );
343 defCompatibleWith( a_sparcv9(), a_noarch(),a_sparc(),a_sparcv8() );
344 defCompatibleWith( a_sparcv9v(), a_noarch(),a_sparc(),a_sparcv8(),a_sparcv9() );
346 defCompatibleWith( a_sparc64(), a_noarch(),a_sparc(),a_sparcv8(),a_sparcv9() );
347 defCompatibleWith( a_sparc64v(), a_noarch(),a_sparc(),a_sparcv8(),a_sparcv9(),a_sparcv9v(),a_sparc64() );
349 defCompatibleWith( a_armv3l(), a_noarch() );
350 defCompatibleWith( a_armv4l(), a_noarch(),a_armv3l() );
351 defCompatibleWith( a_armv4tl(), a_noarch(),a_armv3l(),a_armv4l() );
352 defCompatibleWith( a_armv5l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl() );
353 defCompatibleWith( a_armv5tl(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l() );
354 defCompatibleWith( a_armv5tel(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl() );
355 defCompatibleWith( a_armv5tejl(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel() );
356 defCompatibleWith( a_armv6l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl() );
357 defCompatibleWith( a_armv7l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l() );
358 defCompatibleWith( a_armv8l(), a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l(),a_armv7l() );
360 defCompatibleWith( a_armv6hl(), a_noarch() );
361 defCompatibleWith( a_armv7hl(), a_noarch(),a_armv6hl() );
362 defCompatibleWith( a_armv8hl(), a_noarch(),a_armv7hl() );
363 defCompatibleWith( a_armv7hnl(), a_noarch(),a_armv7hl(),a_armv6hl() );
365 defCompatibleWith( a_armv7nhl(), a_noarch(),a_armv7hnl(),a_armv7hl(),a_armv6hl() );
367 defCompatibleWith( a_armv7thl(), a_noarch(),a_armv7hl() );
368 defCompatibleWith( a_armv7tnhl(), a_noarch(),a_armv7hl(),a_armv7nhl(),a_armv7thl() );
370 defCompatibleWith( a_aarch64(), a_noarch() );
372 defCompatibleWith( a_riscv64(), a_noarch() );
374 defCompatibleWith( a_sh3(), a_noarch() );
376 defCompatibleWith( a_sh4(), a_noarch() );
377 defCompatibleWith( a_sh4a(), a_noarch(),a_sh4() );
379 defCompatibleWith( a_m68k(), a_noarch() );
381 defCompatibleWith( a_mips(), a_noarch() );
382 defCompatibleWith( a_mipsel(), a_noarch() );
383 defCompatibleWith( a_mips64(), a_noarch() );
384 defCompatibleWith( a_mips64el(), a_noarch() );
402 ZYPP_THROW( Exception(
"Need more bits to encode architectures.") );
411 const CompatEntry & assertCompatSetEntry( IdString archStr_r )
412 {
return *
_compatSet.insert( Arch::CompatEntry( archStr_r, nextIdBit() ) ).first; }
416 void defCompatibleWith( IdString targetArch_r,
418 IdString arch1_r = IdString(),
419 IdString arch2_r = IdString(),
420 IdString arch3_r = IdString(),
421 IdString arch4_r = IdString(),
422 IdString arch5_r = IdString(),
423 IdString arch6_r = IdString(),
424 IdString arch7_r = IdString(),
425 IdString arch8_r = IdString(),
426 IdString arch9_r = IdString() )
428 const CompatEntry & target( assertCompatSetEntry( targetArch_r ) );
429 target.addCompatBit( assertCompatSetEntry( arch0_r )._idBit );
430#define SETARG(N) if ( arch##N##_r.empty() ) return; target.addCompatBit( assertCompatSetEntry( arch##N##_r )._idBit )
459 : _entry( &ArchCompatSet::instance().assertDef( a_noarch() ) )
463 : _entry( &ArchCompatSet::instance().assertDef(
IdString(id_r) ) )
467 : _entry( &ArchCompatSet::instance().assertDef( idstr_r ) )
471 : _entry( &ArchCompatSet::instance().assertDef( str_r ) )
475 : _entry( &ArchCompatSet::instance().assertDef( cstr_r ) )
544 if ( cset.size() > 2 )
546 return *(++cset.rbegin());
568 for ( ArchCompatSet::const_iterator it = ArchCompatSet::instance().begin();
569 it != ArchCompatSet::instance().end(); ++it )
571 if ( it->compatibleWith( *targetArch_r.
_entry ) )
573 ret.insert(
Arch(*it) );
const CompatEntry * _entry
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
int compare(const Arch &rhs) const
Arch comparison.
Arch()
Default ctor Arc_noarch.
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
bool isBuiltIn() const
Whether this is a buitin (or known) architecture.
IdString idStr() const
String representation of Arch.
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
Access to the sat-pools string space.
sat::detail::IdType IdType
IdType id() const
Expert backdoor.
static const IdString Empty
Empty string.
An integral type used as BitField.
TInt value() const
Return the value.
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
std::string numstring(char n, int w=0)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
const Arch Arch_empty(IdString::Empty)
Holds an architecture ID and its compatible relation.
void addCompatBit(const CompatBits &idBit_r) const
std::ostream & operator<<(std::ostream &str, const Arch::CompatEntry &obj)
Stream output.
bool compatibleWith(const CompatEntry &targetEntry_r) const
Return whether this is compatible with targetEntry_r.
int compare(const CompatEntry &rhs) const
compare by score, then archStr.
bool operator==(const Arch::CompatEntry &lhs, const Arch::CompatEntry &rhs)
IdString::IdType id() const
bool operator!=(const Arch::CompatEntry &lhs, const Arch::CompatEntry &rhs)
bit::BitField< uint64_t > CompatBits
Bitfield for architecture IDs and compatBits relation.
CompatEntry(IdString archStr_r, CompatBits::IntT idBit_r=1)
CompatEntry(const std::string &archStr_r, CompatBits::IntT idBit_r=1)
static const unsigned size
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
#define ZYPP_DEFINE_ID_HASHABLE(C)
Define hash function for id based classes.